Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/walkdir.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib.rs5
-rw-r--r--src/tests/recursive.rs20
2 files changed, 21 insertions, 4 deletions
diff --git a/src/lib.rs b/src/lib.rs
index bc6b184..37a4d60 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -724,10 +724,7 @@ impl IntoIter {
/// [`filter_entry`]: #method.filter_entry
pub fn skip_current_dir(&mut self) {
if !self.stack_list.is_empty() {
- self.stack_list.pop();
- }
- if !self.stack_path.is_empty() {
- self.stack_path.pop();
+ self.pop();
}
}
diff --git a/src/tests/recursive.rs b/src/tests/recursive.rs
index 27d1590..7d3435c 100644
--- a/src/tests/recursive.rs
+++ b/src/tests/recursive.rs
@@ -990,3 +990,23 @@ fn same_file_system() {
];
assert_eq!(expected, r.sorted_paths());
}
+
+// Tests that skip_current_dir doesn't destroy internal invariants.
+//
+// See: https://github.com/BurntSushi/walkdir/issues/118
+#[test]
+fn regression_skip_current_dir() {
+ let dir = Dir::tmp();
+ dir.mkdirp("foo/a/b");
+ dir.mkdirp("foo/1/2");
+
+ let mut wd = WalkDir::new(dir.path()).max_open(1).into_iter();
+ wd.next();
+ wd.next();
+ wd.next();
+ wd.next();
+
+ wd.skip_current_dir();
+ wd.skip_current_dir();
+ wd.next();
+}