nette / utils

🛠 Lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.
https://doc.nette.org/utils
Other
1.98k stars 147 forks source link

Delete: During the deletion of a folder, additional files may be added. #279

Open janbarasek opened 2 years ago

janbarasek commented 2 years ago

New files may be created by another process while the directory is being deleted. The deletion will then fail. The new implementation repeatedly checks the files in the directory.

Demo:

Snímek obrazovky 2022-01-31 v 13 22 31 Snímek obrazovky 2022-01-31 v 13 32 52

Thanks.

JanTvrdik commented 2 years ago

The error seems expected. You simply cannot delete a directory that is actively being written into.

janbarasek commented 2 years ago

This means that, for example, the cache can never be removed if there are many parallel requests to the application.

How to safely delete the cache contents if there is an error?

For example, the rm -fr temp/cache/* command will always delete the contents safely and not cause an error to be thrown, like Nette.

JanTvrdik commented 2 years ago

This means that, for example, the cache can never be removed if there are many parallel requests to the application.

You can remove individual files, just not the directory itself.

milo commented 2 years ago

For example, the rm -fr temp/cache/* command will always delete the contents safely and not cause an error to be thrown, like Nette.

That's because of -f option. It only mutes errors. Try -r only on rush directory. You get Directory not empty.

janbarasek commented 2 years ago

So could Nette implement a force switch? There are certainly valid cases where this is useful.