Open selendym opened 1 year ago
This also happens when setting .follow_symlinks(false), while filtering out hidden entries, and then encountering a hidden symlink on windows
filter_entries tries to delete the entry twice, wich leads to the iterator exiting the current folder without looking at any other entries
just ran into this by chance
I encountered a similar issue.
test case:
mkdir -p /tmp/test-walkdir/{a,b,c}
for entry in walkdir::WalkDir::new("/tmp/test-walkdir")
.contents_first(true)
.sort_by(|a, b| a.file_name().cmp(&b.file_name()))
.filter_entry(|e| e.file_name().to_string_lossy() != "a")
.into_iter()
{
println!("{}", entry.path().display());
}
output:
/tmp/test-walkdir
missing items b
, c
output after change filter to .filter_entry(|e| e.file_name().to_string_lossy() != "b")
/tmp/test-walkdir/a
/tmp/test-walkdir
missing item c
It seems to have broken the iterator after encountering a filtered entry.
+1, also ran into an issue with filter_entry
and contents_first
that looks a lot like this. the problem goes away when disabling contents_first
Hello.
It seems that when
contents_first
is enabled,filter_entry
misbehaves when the deferred directories are filtered out.Example:
Output:
Expected output for the latter part:
This seems to be caused by double popping
IntoIter.stack_list
:As a fix, a check for
contents_first
in https://github.com/BurntSushi/walkdir/blob/master/src/lib.rs#L1051 could perhaps work. This would not fix direct usage ofskip_current_dir
, however.Best regards.