Moodle Plugins directory: File trash (Orphaned file locator) | Moodle.org
File trash (Orphaned file locator)
The files in the Moodle data folder and backup folders are referenced in the "files" table in the database. If you view the folders themselves you will find the sha1 hash code under which the file has been saved and referenced in the database. If you have any orphaned files (files no longer referenced by the database but still present on your disk) it will be very difficult to find them. This utility enables you to immediately receive a list of orphaned files together with the file type and size. You can download the file to see what it is (the name is a sha1 hash so that won't give you any clues). If you are happy to delete the file you can select it with the checkbox next to it's description and click delete. You will be asked for confirmation before the file is finally deleted.
Please note: This plugin requires the fileinfo PHP extension
$ADMIN->add('reports', new admin_externalpage('report_filetrash', get_string('pluginname', 'report_filetrash'), "$CFG->wwwroot/report/filetrash/index.php",'report/filetrash:view'));
(base on report/security and modify for report_filetrtrash)
Now i get the menu but still get "Section error" when i try delete files.
Exception - RecursiveDirectoryIterator::__construct(/mnt/zion/neo/moodle_courses/student_vet): failed to open dir: No such file or directory
Is there anything I can do to fix it?
Rgds
Petras
I have installed this plugin on our Moodle, it has brought up a huge list of backup files (.mbz) - around 1940 to be precise. I can click on the link and download these so they are present. When I follow the directory path they are not there, also when I try to delete it through the plugin it says "There was a problem deleting the following files" and makes me continue onto the report. Any ideas where these backups are, and why they aren't deleting through the plugin? Would love to clear them off the disk.
Cheers!
Scott
Any chance of including a bit more info from the file (like mod date), and the option to 'table-ize' and/or sort the list? I'm willing to help a bit if that's of interest...
Please feel free to help out if you have any code to contribute. It would be much appreciated.
...guess we have a typo in "filetrash/lang/en/report_filetrash.php".
It must be
$string['filetrash:view'] = 'View the file trash report';
instead of
$string['filtetrash:view'] = 'View the file trash report';
Best,
Johann
1. I created a course
2. I created a File activity and uploaded a large video file. I can confirm that file exists in the filedir by following the hash.
3. I then deleted the course. I can confirm it's deleted in mdl_course table. I also can confirm that the file still exists in the filedir.
4. I run the filetrash plugin. It says "There are no orphaned files in the filedir directory of your moodledata folder"
What does orphaned file mean? I have a file in filedir that should have no database reference considering the course is deleted. Is that not the definition of orphaned file?
Thank you for the help! You're right, there's still a record in the database. It's where filearea="draft". Apparently, draft files don't get deleted from the database when a course with the file is deleted. I'm guessing that the cron cleans up the draft files over time...