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

Cron don't delete some draft files

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5.5
    • Fix Version/s: 2.6.6, 2.7.3
    • Component/s: Files API
    • Labels:
    • Testing Instructions:
      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)
    • Affected Branches:
      MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_26_STABLE, MOODLE_27_STABLE
    • Pull Master Branch:
      wip-MDL-45538-master

      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

              Assignee:
              marina Marina Glancy
              Reporter:
              jackdaniels JD
              Peer reviewer:
              Dan Poltawski
              Integrator:
              Damyon Wiese
              Tester:
              Dave Cooper
              Participants:
              Component watchers:
              Matteo Scaramuccia, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              3 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                10/Nov/14