Moodle
  1. Moodle
  2. MDL-25518

A "File exists" error always occurs when a previously linked file is relinked in an assignment

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 2.0
    • Fix Version/s: None
    • Component/s: Files API
    • Affected Branches:
      MOODLE_20_STABLE
    • Rank:
      2821

      Description

      A "File exists" error always occurs if the following steps are followed.

      1. Link to a file in an assignment.

      2. Save the assignment.

      3. Edit the assignment and remove the link to the file.

      4. Save the assignment.

      5. Edit the assignment and attempt to link to the original file.

      This is a serious issue because the workaround (replacing the assignment with a new one) involves data loss if some students have already submitted work. The workaround may also not be evident since the error suggests that the issue is with the file.

        Issue Links

          Activity

          Hide
          Dongsheng Cai added a comment -

          Petr,

          This related to general file handing, when user removed picture in tinymce, file api won't be able to detect it, the file still associated with text, not sure if we should overwrite the abandoned file here?

          Show
          Dongsheng Cai added a comment - Petr, This related to general file handing, when user removed picture in tinymce, file api won't be able to detect it, the file still associated with text, not sure if we should overwrite the abandoned file here?
          Hide
          Petr Škoda added a comment -

          This is the same issue I was pointing out since the very beginning, there needs to be a way to delete embedded files in the editor, overriding would be an ugly workaround causing other issues. Please try to discuss this with MD again - people are going to report this over and over again because everybody thinks it is a regression.

          The only workaround is to disable Javascript temporarily in browser and then click the edit assignment, but this can not be the official solution imo.

          Show
          Petr Škoda added a comment - This is the same issue I was pointing out since the very beginning, there needs to be a way to delete embedded files in the editor, overriding would be an ugly workaround causing other issues. Please try to discuss this with MD again - people are going to report this over and over again because everybody thinks it is a regression. The only workaround is to disable Javascript temporarily in browser and then click the edit assignment, but this can not be the official solution imo.
          Hide
          Petr Škoda added a comment -

          Oh, I tried the disabling of JS right now and there is a bug somewhere because the link to the draft file was not converted to the standard @@pluginfile@@ format, please retest the JS-less mode.

          Show
          Petr Škoda added a comment - Oh, I tried the disabling of JS right now and there is a bug somewhere because the link to the draft file was not converted to the standard @@pluginfile@@ format, please retest the JS-less mode.
          Hide
          Dongsheng Cai added a comment -

          Petr,
          "the link to the draft file was not converted to the standard @@pluginfile@@ format"
          Are you talking about the link in html editor or draft file manager?

          I have a quick fix for this issue:
          https://github.com/dongsheng/moodle/commit/97bb4ccfe4a0a375739b1e723caf86d9e16fd2c2

          If detected existing file, file picker will try to direct user to draft manager.

          Show
          Dongsheng Cai added a comment - Petr, "the link to the draft file was not converted to the standard @@pluginfile@@ format" Are you talking about the link in html editor or draft file manager? I have a quick fix for this issue: https://github.com/dongsheng/moodle/commit/97bb4ccfe4a0a375739b1e723caf86d9e16fd2c2 If detected existing file, file picker will try to direct user to draft manager.
          Hide
          Brandon Horn added a comment -

          Thanks to everyone who's looking into this issue.

          Is this also a potential (disk) memory leak? Specifically, if I:

          1. Upload a file and link to it in an assignment/page/etc.

          2. Never add another link to the file from anywhere else.

          3. Remove the original link to the file.

          Will the file be removed or will it persist (with no links to it) on the disk?

          Brandon

          Show
          Brandon Horn added a comment - Thanks to everyone who's looking into this issue. Is this also a potential (disk) memory leak? Specifically, if I: 1. Upload a file and link to it in an assignment/page/etc. 2. Never add another link to the file from anywhere else. 3. Remove the original link to the file. Will the file be removed or will it persist (with no links to it) on the disk? Brandon
          Hide
          Petr Škoda added a comment -

          Dongsheng: I removed the file manually, but then when I viewed the resulting page the image was still there because the draftfile link got stored into the database somehow, that should never happen.

          Show
          Petr Škoda added a comment - Dongsheng: I removed the file manually, but then when I viewed the resulting page the image was still there because the draftfile link got stored into the database somehow, that should never happen.
          Hide
          Dongsheng Cai added a comment -

          Brandon, yes, this is a potential disk waste, the deleted links haven't been detected.

          Show
          Dongsheng Cai added a comment - Brandon, yes, this is a potential disk waste, the deleted links haven't been detected.
          Hide
          Dongsheng Cai added a comment -

          Petr,

          I figured out, after you delete the file in draft file manager, file_postupdate_standard_editor failed to find the file in draft area, so it cannot convert the draft file url to @@pluginfile@@ format...

          I am not sure if we should let file_save_draft_area_files delete the dead draft files?

          Show
          Dongsheng Cai added a comment - Petr, I figured out, after you delete the file in draft file manager, file_postupdate_standard_editor failed to find the file in draft area, so it cannot convert the draft file url to @@pluginfile@@ format... I am not sure if we should let file_save_draft_area_files delete the dead draft files?
          Hide
          Dongsheng Cai added a comment -

          CORRECTION

          I was wrong, file_save_draft_area_files will replace all draft file urls here, but I failed to reproduce the problem:
          1. edit submission, add a picture by filepicker, save it
          2. turn off javascript
          3. edit submission, delete the picture using draft file manager
          4. save it, the image cannot be displayed, I checked the image url is pluginfile.php?xxx

          Show
          Dongsheng Cai added a comment - CORRECTION I was wrong, file_save_draft_area_files will replace all draft file urls here, but I failed to reproduce the problem: 1. edit submission, add a picture by filepicker, save it 2. turn off javascript 3. edit submission, delete the picture using draft file manager 4. save it, the image cannot be displayed, I checked the image url is pluginfile.php?xxx
          Hide
          Dongsheng Cai added a comment -

          Hi, Petr

          Can you please review the patch?

          Show
          Dongsheng Cai added a comment - Hi, Petr Can you please review the patch?
          Hide
          Petr Škoda added a comment -

          oh, popping a new window from the language pack? I do not like this idea. I still believe we need a full file manager in the tinymce somewhere, I personally miss the option to delete/manage existing files there a lot.

          Show
          Petr Škoda added a comment - oh, popping a new window from the language pack? I do not like this idea. I still believe we need a full file manager in the tinymce somewhere, I personally miss the option to delete/manage existing files there a lot.
          Hide
          Dongsheng Cai added a comment -

          Petr,

          But we don't have a full file manager at the moment, user have to switch to non javascript to delete it, it is even worse.

          Show
          Dongsheng Cai added a comment - Petr, But we don't have a full file manager at the moment, user have to switch to non javascript to delete it, it is even worse.
          Hide
          Petr Škoda added a comment -

          I was telling you and MD it will end up like this for at least a year. I can not agree with a hack like this now because it would become a permanent solution.

          Show
          Petr Škoda added a comment - I was telling you and MD it will end up like this for at least a year. I can not agree with a hack like this now because it would become a permanent solution.
          Hide
          Dongsheng Cai added a comment -

          Ok, I understand this is not a good solution, but what should we do now?

          Show
          Dongsheng Cai added a comment - Ok, I understand this is not a good solution, but what should we do now?
          Hide
          Petr Škoda added a comment -

          Looks like everybody except Martin expects some kind of file manager to be part of tinymce filepicking. I created several proposals such as tabbed file picker UI, separate file management window, fake current files repository, etc. There might be some other solutions.

          Show
          Petr Škoda added a comment - Looks like everybody except Martin expects some kind of file manager to be part of tinymce filepicking. I created several proposals such as tabbed file picker UI, separate file management window, fake current files repository, etc. There might be some other solutions.
          Hide
          Martin Dougiamas added a comment -

          How do you get from this bug to "Everyone... expects some kind of file manager to be part of tinymce filepicking" ?

          Show
          Martin Dougiamas added a comment - How do you get from this bug to "Everyone... expects some kind of file manager to be part of tinymce filepicking" ?
          Hide
          Petr Škoda added a comment -

          Simply by reading moodle.org posts, triaging tracker and actually asking everybody I know that started using Moodle 2.0.

          Show
          Petr Škoda added a comment - Simply by reading moodle.org posts, triaging tracker and actually asking everybody I know that started using Moodle 2.0.
          Hide
          Petr Škoda added a comment -

          Please vote in MDL-26388 to get this fixed, thanks for the report.

          Show
          Petr Škoda added a comment - Please vote in MDL-26388 to get this fixed, thanks for the report.

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: