From 555c0bb1dfff762d321a87e72443ef9700503062 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 21 Sep 2017 16:29:16 +0200 Subject: [PATCH] Fix Walkdir depth From the documentation of Walkdir::min_depth(): Set the minimum depth of entries yielded by the iterator. The smallest depth is 0 and always corresponds to the path given to the new function on this type. Its direct descendents have depth 1, and their descendents have depth 2, and so on. This means that when we started with "/tmp/store", we end up yielding that exact path in the first iteration. This is exactly what we do _not_ want. Setting the minimal depth to 1 fixes this bug. --- lib/core/libimagstore/src/file_abstraction/fs.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/core/libimagstore/src/file_abstraction/fs.rs b/lib/core/libimagstore/src/file_abstraction/fs.rs index 2c649c22..48c51ebb 100644 --- a/lib/core/libimagstore/src/file_abstraction/fs.rs +++ b/lib/core/libimagstore/src/file_abstraction/fs.rs @@ -159,6 +159,7 @@ impl FileAbstraction for FSFileAbstraction { use walkdir::WalkDir; let i : Result, SE> = WalkDir::new(basepath) + .min_depth(1) .into_iter() .map(|r| { r.map(|e| PathBuf::from(e.path()))