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

DnD: add filename property to dndupload_ajax_processor

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Not a bug
    • Icon: Trivial Trivial
    • None
    • 2.3
    • JavaScript

      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();
      ...

            davosmith Davo Smith
            matteo Matteo Scaramuccia
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

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