Comment by makecheck

7 years ago

There is no “check first” in an ever-changing file system environment that has no atomic operation for something this large. Any “check” is a false sense of security, convincing you that you’re about to do the right thing; meanwhile, any background process could create important stuff in the directory tree you just “checked” and you’d destroy it anyway.

If you could lock down the whole directory tree and then check, it would be moderately safer but you are still assuming the tree contains only what you expect. It’s far wiser to have a list from the start or a file search that you can audit before individually processing files on your list.

Sounds like making the perfect the enemy of the good. Why bother to do any checks of anything when a random flip-flop could go metastable forever and brick your system?