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

repository_filesystem does not like import_file_contents

XMLWordPrintable

    • MOODLE_26_STABLE, MOODLE_27_STABLE, MOODLE_28_STABLE, MOODLE_29_STABLE
    • MOODLE_27_STABLE, MOODLE_28_STABLE
    • wip-MDL-47729-master
    • Hide
      1. set up file system repository, add some images and non-images files there
      2. create file resources as references to image and non-image files from this repo, set up resource to display file type and size
      3. make sure they are displayed ok
      4. update the files in file system repo
      5. wait 1 minute and then refresh the course page
      6. make sure the file resources now display the new size (and thumbnail for image), and when you click on it downloads the new version.
        (Note, that file description is cached in course cache and you need to clear the course cache either by purging or making any modification in the course.)
      Show
      set up file system repository, add some images and non-images files there create file resources as references to image and non-image files from this repo, set up resource to display file type and size make sure they are displayed ok update the files in file system repo wait 1 minute and then refresh the course page make sure the file resources now display the new size (and thumbnail for image), and when you click on it downloads the new version. (Note, that file description is cached in course cache and you need to clear the course cache either by purging or making any modification in the course.)

      Discovered while testing MDL-44548
      repository_filesystem was designed to either always import file content (what we do for images) or never (what we do for non images). Explicit calling of import_file_contents() in random moments breaks it.

      We made a fix already, need to test it and check other repositories if they can be affected by the same thing. Not doing it on Friday afternoon

      diff --git a/repository/filesystem/lib.php b/repository/filesystem/lib.php
      index 039616b..0a32a49 100644
      --- a/repository/filesystem/lib.php
      +++ b/repository/filesystem/lib.php
      @@ -366,7 +366,10 @@ class repository_filesystem extends repository {
                       }
                   } else {
                       // Update only file size so file will NOT be copied into moodle filepool.
      -                $contenthash = null;
      +                $contenthash = sha1_file($filepath);
      +                if ($contenthash !== $file->get_contenthash()) {
      +                    $contenthash = sha1('');
      +                }
                       $filesize = filesize($filepath);
                   }
                   $issyncing = false;
      

            marina Marina Glancy
            marina Marina Glancy
            Damyon Wiese Damyon Wiese
            David Monllaó David Monllaó
            Zachary Durber Zachary Durber
            Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.