-
-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
filter_entry
misbehaves when contents_first
is enabled
#171
Comments
This also happens when setting .follow_symlinks(false), while filtering out hidden entries, 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:
missing items output after change filter to
missing item It seems to have broken the iterator after encountering a filtered entry. |
This comment was marked as duplicate.
This comment was marked as duplicate.
Thanks @kikuomax for the proposed fix. I think there should be one more thing to consider. Wouldn't it be better to provide the contents_first property to the iterator (e.g. deal with the direction of the iterator)? |
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 of
skip_current_dir
, however.Best regards.
The text was updated successfully, but these errors were encountered: