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

DnD: add filename property to dndupload_ajax_processor

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Trivial
    • Resolution: Not a bug
    • Affects Version/s: 2.3
    • Fix Version/s: None
    • Component/s: JavaScript
    • Labels:

      Description

      On looking at the work in MDL-32937, I've noticed that in this amazing improvement as well as in mod_folder there is potentially room for inconsistency being the creation of the uploaded file - via DnD - in the draft area and the subsequent selection done not in the same "DB transaction", trusting it will be actually the first (more recent logic?) file. See it e.g. from the current pull proposal for that issue:

      ...
          file_save_draft_area_files($uploadinfo->draftitemid, $context->id, 'mod_scorm', 'package', 0);
          $fs = get_file_storage();
          $files = $fs->get_area_files($context->id, 'mod_scorm', 'package', 0, 'sortorder, itemid, filepath, filename', false);
          $file = reset($files);
          $hash = key($files);
      ...

      While this is normally true it could happen that more than one user is saving files in the draft area in the same course almost at the same time.

      What about adding a new property, filename, to dndupload_ajax_processor?
      This improvement could improve MDL-32937 current pull with something like:

      ...
          file_save_draft_area_files($uploadinfo->draftitemid, $context->id, 'mod_scorm', 'package', 0);
          $fs = get_file_storage();
          $file = $fs->get_file($contextid, 'mod_scorm', 'package', 0, '/', $uploadinfo->filename);
          $hash = $file->get_contenthash();
      ...

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              davosmith Davo Smith
              Reporter:
              matteo Matteo Scaramuccia
              Participants:
              Component watchers:
              Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: