tape restore: avoid multiple stat calls for same chunk

This commit is contained in:
Dietmar Maurer
2021-04-16 13:17:17 +02:00
parent 1369bcdbba
commit 28570d19a6
3 changed files with 38 additions and 9 deletions

View File

@ -154,10 +154,18 @@ impl DataStore {
}
/// Fast index verification - only check if chunks exists
pub fn fast_index_verification(&self, index: &dyn IndexFile) -> Result<(), Error> {
pub fn fast_index_verification(
&self,
index: &dyn IndexFile,
checked: &mut HashSet<[u8;32]>,
) -> Result<(), Error> {
for pos in 0..index.index_count() {
let info = index.chunk_info(pos).unwrap();
if checked.contains(&info.digest) {
continue;
}
self.stat_chunk(&info.digest).
map_err(|err| {
format_err!(
@ -166,6 +174,8 @@ impl DataStore {
err,
)
})?;
checked.insert(info.digest);
}
Ok(())