diff options
author | Andrew Gallant <jamslam@gmail.com> | 2018-02-02 06:50:55 +0300 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2018-02-02 06:50:55 +0300 |
commit | 2863f281e794ef0a819c45d6afce5fddaad1b31c (patch) | |
tree | 0c1fc89aba91cdd8a9aab5dd21a513fa9fac9201 | |
parent | dc4c1ccea153419b92d41787fa34009dfa2f85e1 (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.rs | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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; |