Uploaded image for project: '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
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 2.0
    • Fix Version/s: None
    • Component/s: Files API
    • Affected Branches:
      MOODLE_20_STABLE

      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.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              dongsheng 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 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
              skodak Petr Skoda 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
              skodak Petr Skoda 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
              skodak Petr Skoda 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
              skodak Petr Skoda 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 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 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
              bhorn 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
              bhorn 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
              skodak Petr Skoda 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
              skodak Petr Skoda 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 Dongsheng Cai added a comment -

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

              Show
              dongsheng Dongsheng Cai added a comment - Brandon, yes, this is a potential disk waste, the deleted links haven't been detected.
              Hide
              dongsheng 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 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 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 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 Dongsheng Cai added a comment -

              Hi, Petr

              Can you please review the patch?

              Show
              dongsheng Dongsheng Cai added a comment - Hi, Petr Can you please review the patch?
              Hide
              skodak Petr Skoda 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
              skodak Petr Skoda 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 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 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
              skodak Petr Skoda 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
              skodak Petr Skoda 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 Dongsheng Cai added a comment -

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

              Show
              dongsheng Dongsheng Cai added a comment - Ok, I understand this is not a good solution, but what should we do now?
              Hide
              skodak Petr Skoda 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
              skodak Petr Skoda 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
              dougiamas 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
              dougiamas 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
              skodak Petr Skoda added a comment -

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

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

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

              Show
              skodak Petr Skoda 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: