]> git.proxmox.com Git - proxmox-backup.git/commitdiff
mark_used_chunks: simply ignore vanished files
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 16 Oct 2020 06:01:38 +0000 (08:01 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 16 Oct 2020 06:10:46 +0000 (08:10 +0200)
In case a prune operation removed a file in the meantime.

src/backup/datastore.rs

index 7dd2624c825dfff4e528f40a837607d7997455e7..9bd1b769efade03dddf72165408fdd8b7c982e8b 100644 (file)
@@ -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;