uutils / findutils

Rust implementation of findutils
MIT License
280 stars 35 forks source link

Implement `-ignore_readdir_race` and `-noignore_readdir_race` #377

Open hanbings opened 1 month ago

hanbings commented 1 month ago

refer: https://www.gnu.org/software/findutils/manual/html_node/find_html/Directories.html

Option: -ignore_readdir_race
If a file disappears after its name has been read from a directory but 
before find gets around to examining the file with stat, don’t issue an error message. 
If you don’t specify this option, an error message will be issued.

Furthermore, find with the ‘-ignore_readdir_race’ option will ignore errors of 
the ‘-delete’ action in the case the file has disappeared since the parent directory was read: 
it will not output an error diagnostic, and the return code of the ‘-delete’ action will be true.

This option can be useful in system scripts (cron scripts, for example) that examine areas of 
the filesystem that change frequently (mail queues, temporary directories, and so forth), 
because this scenario is common for those sorts of directories. 
Completely silencing error messages from find is undesirable, 
so this option neatly solves the problem. 
There is no way to search one part of the filesystem with this option on and 
part of it with this option off, though. 
When this option is turned on and find discovers that one of the start-point files specified on 
the command line does not exist, no error message will be issued.

Option: -noignore_readdir_race
This option reverses the effect of the ‘-ignore_readdir_race’ option.