[pbs-devel] [PATCH v5 proxmox-backup 1/2] garbage collection: fail on ArchiveType::Blob in open index reader
Christian Ebner
c.ebner at proxmox.com
Wed Apr 16 12:49:59 CEST 2025
Instead of returning a None, fail if the open index reader is called
on a blob file. Blobs cannot be read as index anyways and this allows
to distinguish cases where the index file cannot be read because
vanished.
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
Changes since version 4:
- Adapt open_index_reader to fail for archive type blob, allows
detection of missing index files.
pbs-datastore/src/datastore.rs | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index aa38e2ac1..333f5f8d2 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -1031,13 +1031,15 @@ impl DataStore {
Ok(list)
}
- // Similar to open index, but ignore index files with blob or unknown archive type.
- // Further, do not fail if file vanished.
- fn open_index_reader(&self, absolute_path: &Path) -> Result<Option<Box<dyn IndexFile>>, Error> {
+ // Similar to open index, but return with Ok(None) if index file vanished.
+ fn open_index_reader(
+ &self,
+ absolute_path: &Path,
+ ) -> Result<Option<Box<dyn IndexFile>>, Error> {
let archive_type = match ArchiveType::from_path(absolute_path) {
- Ok(archive_type) => archive_type,
// ignore archives with unknown archive type
- Err(_) => return Ok(None),
+ Ok(ArchiveType::Blob) | Err(_) => bail!("unexpected archive type"),
+ Ok(archive_type) => archive_type,
};
if absolute_path.is_relative() {
@@ -1064,7 +1066,7 @@ impl DataStore {
.with_context(|| format!("can't open dynamic index '{absolute_path:?}'"))?;
Ok(Some(Box::new(reader)))
}
- ArchiveType::Blob => Ok(None),
+ ArchiveType::Blob => bail!("unexpected archive type blob"),
}
}
@@ -1151,6 +1153,11 @@ impl DataStore {
worker.check_abort()?;
worker.fail_on_shutdown()?;
+ match ArchiveType::from_path(&file) {
+ Ok(ArchiveType::FixedIndex) | Ok(ArchiveType::DynamicIndex) => (),
+ Ok(ArchiveType::Blob) | Err(_) => continue,
+ }
+
let mut path = snapshot.backup_dir.full_path();
path.push(file);
--
2.39.5
More information about the pbs-devel
mailing list