From e07620028da71e09c2c7fea853d1a0f25b73d528 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 16 Oct 2020 08:01:38 +0200 Subject: [PATCH] mark_used_chunks: simply ignore vanished files In case a prune operation removed a file in the meantime. --- src/backup/datastore.rs | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/backup/datastore.rs b/src/backup/datastore.rs index 7dd2624c..9bd1b769 100644 --- a/src/backup/datastore.rs +++ b/src/backup/datastore.rs @@ -460,13 +460,25 @@ impl DataStore { worker.check_abort()?; tools::fail_on_shutdown()?; - if let Ok(archive_type) = archive_type(&path) { - if archive_type == ArchiveType::FixedIndex { - let index = self.open_fixed_reader(&path)?; - self.index_mark_used_chunks(index, &path, status, worker)?; - } else if archive_type == ArchiveType::DynamicIndex { - let index = self.open_dynamic_reader(&path)?; - self.index_mark_used_chunks(index, &path, status, worker)?; + let full_path = self.chunk_store.relative_path(&path); + match std::fs::File::open(&full_path) { + Ok(file) => { + if let Ok(archive_type) = archive_type(&path) { + if archive_type == ArchiveType::FixedIndex { + let index = FixedIndexReader::new(file)?; + self.index_mark_used_chunks(index, &path, status, worker)?; + } else if archive_type == ArchiveType::DynamicIndex { + let index = DynamicIndexReader::new(file)?; + self.index_mark_used_chunks(index, &path, status, worker)?; + } + } + } + Err(err) => { + if err.kind() == std::io::ErrorKind::NotFound { + // simply ignore vanished files + } else { + return Err(err.into()); + } } } done += 1;