Best practice when deleting files manually from moodledata

Best practice when deleting files manually from moodledata

by Ferran Hj -
Number of replies: 4
Hello,

There is a course for which heavy files that have been unused for more than a year still remain, so I decided to try and remove them manually.

What I did is simply find their path using contenthash of the database entry. I could check that those were indeed the heavy files and could delete them via the FTP manager.

After deleting these files, are there any additional steps I should follow? Such as to force the database to refresh and delete the pertinent entries, etc.

Thank you!

Average of ratings: -
In reply to Ferran Hj

Re: Best practice when deleting files manually from moodledata

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
The best practice? There is moosh for such back-end operations.

Did you miss the warning.txt in moodledata/filedir? (attached)
In reply to Visvanath Ratnaweera

Re: Best practice when deleting files manually from moodledata

by Ferran Hj -
Thank you. This Moosh tool seems very advanced for me, as I do not know how to connect to the Moodle via the cmd to begin with. We just have access to a Plesk platform. I will try to find time to sit down and see how to use that.

Will Moodle eventually realize through any scheduled tasks that the files referenced in the table have been deleted?
In reply to Ferran Hj

Re: Best practice when deleting files manually from moodledata

by Ferran Hj -
Following this thread: https://moodle.org/mod/forum/discuss.php?d=383397

I proceeded to manually delete the entries of the pertinent files.

Using the "list course files" plugin, I could check before deleting the database entry that indeed the image/video could not be found, and after deleting the database entry, it disappeared from the list of files in the course.
Average of ratings: Useful (1)
In reply to Ferran Hj

Re: Best practice when deleting files manually from moodledata

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Thanks for reporting back!

If you take that much trouble, why not click around and see whether you can remove them in the Moodle GUI. In the original post you said _unused_ files. May be they are still linked to something. You know that a single file in the filedir may be referenced from many places.

Anyway, the main thing, this solution worked for you.