I have two related questions regarding the deletion of uploaded files in ver 2.9.
I, as an administrator, have uploaded various video files and then have uploaded newer files that replace the original files. The newer files do not have the same name. So, these older, large files are uselessly taking up space on disk and I would like to delete them.
Question 1) When you delete a file from a resource record (for example, a file or a videofile resource), I presume that you are just removing the link from the physical file in moodledata to the resource record, but the physical file is itself not deleted. If this is so, then how to delete the physical file from disk?
Question 2) Following up on that question, if the same physical file is linked to two or more different resources, is there a way to identify within Moodle to which resources it is linked? And if not, can someone provide the sql required to find out within the database?
If you upload a new file, you effectively delete the old file if it is no longer used (anywhere).
In actual fact it is moved to the 'trashdir' and will be cleaned up by a period schuduled task in due course.
Thank you, Howard.
So what you're saying is, for example, if I have the file old.mp4 used by resource a and by resource b, and then I upload file new1.mp4 to resource A and I upload file new2.mp4 to resource B, then the system will automatically move old.mp4 to trashdir and will then delete it via a cron job. However, if I do not upload anything new to resource B, then the system will not move old.mp4 to trashdir. Is that correct?
And what about this scenario: I had uploaded old.mp4 to resource A, but nowhere else, and later I deleted old.mp4 from resource A. The system then moves old.mp4 to trashdir. Is that correct?
Are these moves to trashdir and deletion via a cron job logged anywhere? If so, what log file would that be?
IF you replace the old file (however you do it) it becomes 'unlinked' from that resource. A file's contents are hashed and referenced in a database table, so the physical file is only stored once. Anyway, when that hash/file is unlinked for the final time and Moodle determines that it is no longer used anywhere it is moved to the trash.
I think in reality, it may be possible to 'beat' the delete system and end up with a few orphaned files but that's how it is supposed to work (and generally does).