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

Folder activity problem with alias from repositories

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.1.10, 3.2.7, 3.3.3, 3.4.1
    • Fix Version/s: 3.3.5, 3.4.2
    • Component/s: Files API
    • Labels:
    • Testing Instructions:
      Hide
      1. Create a file (not empty) by hand in (moodledata/repository/mydir/myfile.txt)
      2. Add a "File System" repository and configure it correctly to point to the mydir repository
      3. Add a Dropbox repository and configure it
      4. Ensure that you have a text file in your dropbox account
      5. Edit repository/dropbox/lib.php and comment out all calls to of import_external_file_contents
      6. Create a course.
      7. Add a "folder" activity and in this folder:
        1. add a file (myfile.txt) as an alias in the repository.
        2. add the file from your dropbox repo as an alias in the repository
      8. Save and Display
      9. Click the Download folder link
      10. Unzip the resultant zip
        1. Confirm that both files have content
      Show
      Create a file (not empty) by hand in (moodledata/repository/mydir/myfile.txt) Add a "File System" repository and configure it correctly to point to the mydir repository Add a Dropbox repository and configure it Ensure that you have a text file in your dropbox account Edit repository/dropbox/lib.php and comment out all calls to of import_external_file_contents Create a course. Add a "folder" activity and in this folder: add a file (myfile.txt) as an alias in the repository. add the file from your dropbox repo as an alias in the repository Save and Display Click the Download folder link Unzip the resultant zip Confirm that both files have content
    • Affected Branches:
      MOODLE_31_STABLE, MOODLE_32_STABLE, MOODLE_33_STABLE, MOODLE_34_STABLE
    • Fixed Branches:
      MOODLE_33_STABLE, MOODLE_34_STABLE
    • Pull Master Branch:
      MDL-61253-master

      Description

      Hello,

      One of our clients found a problem and we investigated it.

      Problem:
      Take a clean Moodle 3.X platform
      Add a "File System" repository and configure it correctly
      Create a file (not empty) by hand in the repository (moodledata/repository/mydir/myfile. txt)
      Create a course.
      Add a "folder" activity and in this folder, add a file (myfile.txt) as an alias in the repository.
      On the "view. php" page of the folder activity :
      If you click on the file, it is well downloaded.
      So far everything is working well.
      On the other hand, if you decide to download the folder, you get a zip with an empty file.

      Explanation:

      When you create an alias, you create an empty file that is used as alias in moodledata filedir.
      And when you download the folder, it is this file (alias instead of the real file) that is added in the generated zip.
      While when downloading the file (when you click on it), the file is well found (you download the real file and not the empty alias)

      Code level explanation:

      When we download a file, if the file is in a repository, we call a function of this repository and it is this repository that manages the download of the file.
      When you add a file to an archive, the archive manager does not take care of the repository and only manages files in the file filedir of Moodle and that's why you get the empty file.

      Correction: (for Moodle 3.4)

       

      See corr.diff

      Correction limits:

      Correction applies ONLY for file system repository, not the others !
      I think all other repositories will cause problems

      How do you feel about that?

      Kind Regards

      Olivier

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                19/Mar/18