Skip to content

Commit 4a464f2

Browse files
committed
better verify progress printing (#287)
1 parent 831397c commit 4a464f2

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

Cargo.lock

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

git-odb/src/store_impls/dynamic/verify.rs

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::time::Instant;
12
use std::{
23
ops::Deref,
34
sync::atomic::{AtomicBool, Ordering},
@@ -120,8 +121,17 @@ impl super::Store {
120121
}
121122
let files = slot.files.load();
122123
let files = Option::as_ref(&files).ok_or(integrity::Error::NeedsRetryDueToChangeOnDisk)?;
124+
let progress_message = |path: &std::path::Path| {
125+
format!(
126+
"Checking integrity: {}",
127+
path.file_name()
128+
.map(|f| f.to_string_lossy())
129+
.unwrap_or_else(std::borrow::Cow::default)
130+
)
131+
};
123132

124-
match files {
133+
let start = Instant::now();
134+
let (mut child_progress, num_objects) = match files {
125135
IndexAndPacks::Index(bundle) => {
126136
let index;
127137
let index = match bundle.index.loaded() {
@@ -144,7 +154,7 @@ impl super::Store {
144154
data,
145155
options: options.clone(),
146156
}),
147-
progress.add_child("Checking integrity"),
157+
progress.add_child(progress_message(index.path())),
148158
should_interrupt,
149159
)?;
150160
statistics.push(IndexStatistics {
@@ -155,6 +165,7 @@ impl super::Store {
155165
.expect("pack provided so there are stats"),
156166
),
157167
});
168+
(outcome.progress, index.num_objects())
158169
}
159170
IndexAndPacks::MultiIndex(bundle) => {
160171
let index;
@@ -166,7 +177,7 @@ impl super::Store {
166177
}
167178
};
168179
let outcome = index.verify_integrity(
169-
progress.add_child("Checking integrity"),
180+
progress.add_child(progress_message(index.path())),
170181
should_interrupt,
171182
options.clone(),
172183
)?;
@@ -183,8 +194,15 @@ impl super::Store {
183194
.collect(),
184195
),
185196
});
197+
(outcome.progress, index.num_objects())
186198
}
187-
}
199+
};
200+
201+
child_progress.show_throughput_with(
202+
start,
203+
num_objects as usize,
204+
git_features::progress::count("objects").expect("set"),
205+
);
188206
progress.inc();
189207
}
190208

0 commit comments

Comments
 (0)