Is the WalkDir crate fine with the file system changing while running?

I'm writing a program that iterates over all files on the computer (aka. WalkDir::new("/") with the crate). Can I use WalkDir for this or do I have to write something myself? Obviously the file system could change a lot in this time, but I still need it to work with more or less with no problems (meaning it could skip some new, moved or renamed files, but the unaffected part must still work).

The documentation doesn't say anything about it.

Thanks!

Author of walkdir here.

It's not mentioned in the docs because it's not clear what there is to say here to be honest. Like, I don't think there are any guarantees that can be given beyond what your operating system gives you. walkdir is just basically doing readdir recursively and giving you the results. Depending on options and platform, walkdir might also do an additional stat call on results returned from readdir. So if those files got removed between readdir and the stat call, then obviously that stat call will fail. But that doesn't cause walkdir to fall over. It will happily report the error and keep going. It will be up to you to deal with the error.

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.