Closed andrewbanchich closed 3 years ago
IntoIter
doesn't override the count
method, so I don't really see a reason for this and I doubt this is a problem in walkdir
. I'd encourage you to debug this further or find a way to make a solid reproducible example. Otherwise, if this is a problem in walkdir
, this is unlikely to get fixed.
For example, what is the output of:
let files = || {
WalkDir::new("./").into_iter().filter(|path| match path {
Ok(p) => !p.path().is_dir(),
Err(_) => true,
})
};
println!("Iter count: {}", files().count());
println!("Iter count: {}", files().count());
Interesting... That second count worked! However, I have no idea what could be causing that.
Wouldn't it likely be related to something in WalkDir since Iterator::count
uses Iterator::fold
which uses next
, which is something implemented by WalkDir?
I don't see how. They are completely independent executions. I'm afraid this will require a solid reproduction or you'll need to debug this bug on your own. If it were me, I would start inserting println calls to isolate the first Windows syscall that returns an unexpected result. And then hopefully you can reconstruct a more minimal example, perhaps without using walkdir at all.
Thanks! I'll see what I can find.
Example:
When I run this on a
\\SomeRemoteServer\C$
directory, it will quickly displayIter count: 0
and then eventuallyReal count: 1530
.When testing by creating a local administrative share
\\MyIPAddress\TestShare$
, I don't run into this issue.