Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-45538

Cron don't delete some draft files

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.5.5
    • 2.6.6, 2.7.3
    • Files API
    • MOODLE_25_STABLE
    • MOODLE_26_STABLE, MOODLE_27_STABLE
    • wip-MDL-45538-master
    • Hide

      Covered by unittest but in case manual testing is needed:

      1. locate several records in the database table mdl_files that have the same (contextid, component, filearea, itemid)
      2. remove the one that has filename = '.'
      3. upgrade
      4. make sure the record in DB is created and the timecreated and timemodified for it is the same as in other records (or maximum if they are different)
      Show
      Covered by unittest but in case manual testing is needed: locate several records in the database table mdl_files that have the same (contextid, component, filearea, itemid) remove the one that has filename = '.' upgrade make sure the record in DB is created and the timecreated and timemodified for it is the same as in other records (or maximum if they are different)

    Description

      Hi,

      I have a concern about the old draft files. I understand from reading the docs and forum posts that the cron should be deleting drafts older than 4 days. Now, we have been looking into the files space usage and found out that we have a bunch of draft files older than 4 days (some going back to 2012) stuck into mdl_files and actually existing on the server in moodledata/filedir. These files can't be seen from Moodle GUI and so, cannot be deleted by users. They weight around 450Mb, which is not much, but I don't like the idea of unused files stacking up in my back.

      For example, this video.flv file from mdl_files created on 2013-09-24:

      id contenthash pathnamehash contextid component filearea itemid filepath filename userid filesize mimetype status source author license timecreated timemodified sortorder referencefileid referencelastsync referencelifetime
      77777 dcb26502c74cbb0efd812be410a2d7149e5e256c d9597600857b3e80cb1634b03a1a2229bacd6b19 100 user draft 360321045 / Video.flv 23 189162431 video/x-flv 0 O:8:"stdClass":2:{s:6:"source";s:9:"Video.flv";s:8... zzz zzzzzz allrightsreserved 1380060641 1380060646 0 NULL NULL NULL

      In the file_storage->cron (/filestorage/file_storage.php), the query didn't retrieve it because of the filename = '.' clause:

      $sql = "SELECT *
                        FROM {files}
                       WHERE component = 'user' AND filearea = 'draft' AND filepath = '/' AND filename = '.'
                             AND timecreated < :old";
      

      Is something wrong in the cron?

      Attachments

        Issue Links

          Activity

            People

              marina Marina Glancy
              jackdaniels JD
              Dan Poltawski Dan Poltawski
              Damyon Wiese Damyon Wiese
              Dave Cooper Dave Cooper
              Matteo Scaramuccia, David Woloszyn, Huong Nguyen, Jake Dallimore, Michael Hawkins, Stevani Andolo
              Votes:
              3 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                10/Nov/14