]> git.proxmox.com Git - proxmox-backup.git/blobdiff - src/backup/datastore.rs
backup/datastore.rs: list all index files using walkdir crate
[proxmox-backup.git] / src / backup / datastore.rs
index 35b2acc3dfcff2e8769d6cb82aa3718f1521ec7b..7ba912ba88d23f97642bc9179c9e4ad2c8df7664 100644 (file)
@@ -134,17 +134,25 @@ impl DataStore {
 
         let mut list = vec![];
 
-        // fixme: walk into subdirs ...
-        for entry in std::fs::read_dir(base)? {
-            let entry = entry?;
-            if entry.file_type()?.is_file() {
-                let path = entry.path();
-                if let Some(ext) = path.extension() {
-                    if ext == "iidx" {
-                        list.push(path);
-                    } else if ext == "aidx" {
-                        list.push(path);
-                    }
+        use walkdir::WalkDir;
+
+        let walker = WalkDir::new(&base).same_file_system(true).into_iter();
+
+        // make sure we skip .chunks (and other hidden files to keep it simple)
+        fn is_hidden(entry: &walkdir::DirEntry) -> bool {
+            entry.file_name()
+                .to_str()
+                .map(|s| s.starts_with("."))
+                .unwrap_or(false)
+        }
+
+        for entry in walker.filter_entry(|e| !is_hidden(e)) {
+            let path = entry?.into_path();
+            if let Some(ext) = path.extension() {
+                if ext == "iidx" {
+                    list.push(path);
+                } else if ext == "aidx" {
+                    list.push(path);
                 }
             }
         }