backup/datastore.rs: list all index files using walkdir crate

This commit is contained in:
Dietmar Maurer 2019-01-18 12:24:58 +01:00
parent ff3d3100d4
commit 95cea65b04
2 changed files with 20 additions and 11 deletions

View File

@ -29,4 +29,5 @@ chrono = "0.4.6" # Date and time library for Rust
openssl = "0.10.16" openssl = "0.10.16"
siphasher = "0.3" siphasher = "0.3"
endian_trait = "0.6.0" endian_trait = "0.6.0"
walkdir = "2"

View File

@ -134,17 +134,25 @@ impl DataStore {
let mut list = vec![]; let mut list = vec![];
// fixme: walk into subdirs ... use walkdir::WalkDir;
for entry in std::fs::read_dir(base)? {
let entry = entry?; let walker = WalkDir::new(&base).same_file_system(true).into_iter();
if entry.file_type()?.is_file() {
let path = entry.path(); // make sure we skip .chunks (and other hidden files to keep it simple)
if let Some(ext) = path.extension() { fn is_hidden(entry: &walkdir::DirEntry) -> bool {
if ext == "iidx" { entry.file_name()
list.push(path); .to_str()
} else if ext == "aidx" { .map(|s| s.starts_with("."))
list.push(path); .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);
} }
} }
} }