Your Moodle version

Reports: File trash (Orphaned file locator)

report_filetrash
Maintained by Picture of Barry Oosthuizen Barry Oosthuizen
Utility for listing, downloading and deleting orphaned files (file no longer referenced in the files db table but still present in the Moodle data and/or backup directory
1k
142
8

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

Screenshots

Screenshot #0

Contributors

Picture of Barry Oosthuizen
Barry Oosthuizen (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Picture of David Mudrák
    Thu, Jun 5, 2014, 5:24 PM
    Hi Barry. Thanks for sharing this report with the community and for fixing the issues mentioned above. I am going to approve it now.
    During the review of the plugin, I found couple of issues that should raise your attention and be fixed in future updates of your
    plugin.

    Your report throws PHP "Notice: Array to string conversion in report/filetrash/lib.php on line 187". Please double check the arrays
    processing there.

    I believe your report should exclude the file /warning.txt in the filepool. It is supposed to stay there for admins who browse the
    moodledata directory.

    I noticed that you create functions in the global PHP scope without the valid frankenstyle prefix. This is strongly discouraged in
    order to prevent collisions with (current and/or future) core code or some other plugin. See
    http://docs.moodle.org/dev/Coding_style#Functions_and_Methods for details.

    Please note that leading and trailing whitespace in strings is not supported by Moodle localisation tools. Translators of your
    plugin will be unable to have them in their non-English strings. Please fix your English language pack so that it does not rely on
    whitespace around the string value.

    I believe you would consider this feedback for further versions of your report. Said that, you are cleared to land now. Runway free,
    welcome to Plugins directory!
  • Picture of Anita Bridgman
    Tue, Aug 12, 2014, 2:38 PM
    Hi Barry, I like the sound of this add-on and we were quite keen to try it out. Is there any plan to update this addon to be compatible with Moodle 2.6?
    We just tried installing this on our 3.6.3+ site and when we go to the report we just get a blank page.
    Thanks
    Anita
  • Picture of Barry Oosthuizen
    Sun, May 17, 2015, 11:30 PM
    Hi Anita, I have updated this plugin with a new version which also supports Moodle 2.6.
  • Picture of Sarah Cotton
    Mon, May 18, 2015, 11:28 PM
    I too had a blank screen on installation - this was solved by enabling php_fileinfo.dll
  • Picture of Barry Oosthuizen
    Tue, May 19, 2015, 4:10 AM
    Thanks Sarah. I have updated the description and the documentation to reflect this requirement
  • Picture of Blair F.
    Fri, May 22, 2015, 2:30 AM
    I am also getting an empty file list. I've checked with our I.T. guy and he says, "It should be okay… it comes with the php-common extension: fileinfo support => enabled" If we, in fact, have no files would the report return "no files found?"
  • Picture of Barry Oosthuizen
    Fri, May 22, 2015, 2:40 AM
    If you have no orphaned files (files which are no longer referenced in the database) a message should appear saying "no files found". Valid files (ones referenced in the db) are not listed.

    If you believe there is a bug you could set debugging to developer and report back what it says here (if anything)
  • Picture of Jacques Monnard
    Wed, May 27, 2015, 9:06 PM
    Hi Barry,

    We are also getting a blank page on Moodle 2.7. With debugging enabled, it appears there is a problem with php reaching its memory limit. Now we could increase the memory limit in php.ini, but our installation is working fine with the current limit, and we would prefer not having to change this. Instead, you could use the Moodle function "raise_memory_limit" in your plugin to temporarily increase the limit. This is what Moodle core code and plugins do when they require additional memory for some operations (e.g. backups). I tried this with your code and it works fine.

    Jacques
  • Picture of Barry Oosthuizen
    Thu, May 28, 2015, 4:36 AM
    Hi Jacques, Thanks for the useful report. I have updated the code now. Please let me know if it works ok now.
  • Picture of Jacques Monnard
    Thu, May 28, 2015, 2:57 PM
    Hi Barry,

    It's working fine now, thanks !

    Jacques
  • Picture of Iñigo Zendegi Urzelai
    Fri, May 29, 2015, 5:00 PM
    Hi,

    I've tested the plugin in several Moodle 2.7 instances and it works, but it has a performance issue: when there are many orphaned files in the list it takes several minutes to load the list (that's ok), but if only one file is checked to be deleted it takes several minutes to show the confirmation message and to delete that file. It seems like the plugin is executing something (maybe the query that loads the list) before the confirmation message and the deletion too, and I think it shouldn't, should it?
  • Picture of Barry Oosthuizen
    Thu, Jun 18, 2015, 4:21 AM
    Hi Iñigo, thanks for your feedback. I made a small change which will cut out one of the long file comparisons (so its 33% faster now).
  • Picture of Marcus Green
    Tue, Jun 30, 2015, 11:57 PM
    I found this report timed out on our site, which didn't surprise me as it does have a large number of files. I made it work by editing the file classes/classes.php and commenting out the lines
    //$finfo = finfo_open(FILEINFO_MIME_TYPE);
    //$mime = (string)finfo_file($finfo, $pathfile[0]);
    And adding a dummy value for the $mime variable as follows.
    $mime='mime';
    After that it ran fairly quickly and I can live without knowing what the mime type is. The author might consider adding this as a toggle in the settings or as an option when starting to run the report. Anyway, many thanks for developing this and making it available.
  • Picture of Barry Oosthuizen
    Mon, Aug 3, 2015, 6:32 AM
    Thanks for the idea Marcus. I have updated the plugin to have a setting to show / hide file extensions. Hiding them will make the report much faster and hopefully prevent timeouts.
  • Picture of Geir Johansen
    Thu, Aug 20, 2015, 4:30 PM
    I've installed this plugin in Moodle 2.9.1+ but it seems like the plugin is not adding itself the admin menu. It's possible to bring up the file report by manually entering the /report/filetrash/index.php URL, but a "Section error" appears when trying to delete files. So perhaps some work is needed before this plugin is compatible with Moodle 2.9 ?
1 2
Please login to post comments