Closed jjkester closed 7 years ago
At first we get all files from MEDIA directory, and then we get all files from DB. And we remove all files presented in MEDIA and not presented in DB.
Correct me if I'm wrong and bring more detail example, but if somewere in between new files will be added we wont remove them, because we will be looking only on the files retrieved at the first step.
Oh, I might have made a mistake reading the code then. Oops, sorry.
With large databases and many files there can be a delay between getting the used files from the database and all the files from disk. Inbetween a file may have been uploaded, which will then be deleted by the script. While this is an edge case and not very likely to happen, I would suggest adding an option (or making it default) to only remove files that have not been modified for some length of time, for example a couple of minutes or an hour.
If you like this idea I'll be happy to prepare a pull request adding this functionality, but before I do that I am wondering what your thoughts are.