[pbs-devel] [RFC proxmox-backup 2/4] datastore: allow to specify sub-directory for index file listing

Christian Ebner c.ebner at proxmox.com
Wed Apr 16 16:18:01 CEST 2025


Extend the list_index_files helper to allow passing a sub-directory
to it. This will be used to fetch only index files from the `.trash`
directory, ignored by regular listing since hidden folders are not
considered.

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
 pbs-datastore/src/datastore.rs | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index 3fde8b871..97b78f000 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -972,8 +972,15 @@ impl DataStore {
     /// The filesystem is walked recursevly to detect index files based on their archive type based
     /// on the filename. This however excludes the chunks folder, hidden files and does not follow
     /// symlinks.
-    fn list_index_files(&self) -> Result<HashSet<PathBuf>, Error> {
-        let base = self.base_path();
+    /// If a subdirectory is provided, only that is scanned for index files.
+    fn list_index_files(&self, subdir: Option<PathBuf>) -> Result<HashSet<PathBuf>, Error> {
+        let mut base = self.base_path();
+        if let Some(subdir) = subdir {
+            base.push(subdir);
+            if !base.exists() {
+                return Ok(HashSet::new());
+            }
+        }
 
         let mut list = HashSet::new();
 
@@ -1132,7 +1139,7 @@ impl DataStore {
         // seen by the regular logic and the user is informed by the garbage collection run about
         // the detected index files not following the iterators logic.
 
-        let mut unprocessed_index_list = self.list_index_files()?;
+        let mut unprocessed_index_list = self.list_index_files(None)?;
         let mut index_count = unprocessed_index_list.len();
 
         let mut chunk_lru_cache = LruCache::new(cache_capacity);
-- 
2.39.5





More information about the pbs-devel mailing list