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:
authorAndrew Gallant <jamslam@gmail.com>2018-02-02 06:50:55 +0300
committerAndrew Gallant <jamslam@gmail.com>2018-02-02 06:50:55 +0300
commit2863f281e794ef0a819c45d6afce5fddaad1b31c (patch)
tree0c1fc89aba91cdd8a9aab5dd21a513fa9fac9201
parentdc4c1ccea153419b92d41787fa34009dfa2f85e1 (diff)
windows: more carefuly is_dir checking
This fixes a bug where a symlink was followed even if the user did not request it. Namely, on Windows, a symlink can be interpreted as both a symlink and a directory, given our new is_dir checking.
-rw-r--r--src/lib.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lib.rs b/src/lib.rs
index a97aecf..29df0c9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -800,10 +800,11 @@ impl IntoIter {
if self.opts.follow_links && dent.file_type().is_symlink() {
dent = itry!(self.follow(dent));
}
- if dent.is_dir() {
+ let is_normal_dir = !dent.file_type().is_symlink() && dent.is_dir();
+ if is_normal_dir {
itry!(self.push(&dent));
}
- if dent.is_dir() && self.opts.contents_first {
+ if is_normal_dir && self.opts.contents_first {
self.deferred_dirs.push(dent);
None
} else if self.skippable() {
@@ -1196,7 +1197,7 @@ where P: FnMut(&DirEntry) -> bool
Some(result) => itry!(result),
};
if !(self.predicate)(&dent) {
- if dent.file_type().is_dir() {
+ if dent.is_dir() {
self.it.skip_current_dir();
}
continue;