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

Cannot upload over top of existing file

    XMLWordPrintable

    Details

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

      Description

      I created a file resource from an image named "cap.png". I then navigated to the Files area and went to the "Cap (File)" directory and then to "Files and subfolders" then tried to upload a new copy of "cap.png" and it threw this error:

      Debug info: ERROR: duplicate key value violates unique constraint "mdl_file_pat_uix"
      INSERT INTO mdl_files (contextid,filearea,itemid,filepath,filename,timecreated,timemodified,mimetype,userid,source,author,license,filesize,contenthash,pathnamehash) VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15) RETURNING id
      [array (
      'contextid' => '41',
      'filearea' => 'resource_content',
      'itemid' => '0',
      'filepath' => '/',
      'filename' => 'cap.png',
      'timecreated' => 1275378556,
      'timemodified' => 1275378556,
      'mimetype' => 'image/png',
      'userid' => '2',
      'source' => NULL,
      'author' => NULL,
      'license' => NULL,
      'filesize' => 25520,
      'contenthash' => '1d5cb0b4a461aeba7b6e6fb5d1e1f37a29a2eb8b',
      'pathnamehash' => '283fee45dd2177b7749124329a769567b2e87da9',
      )]
      Stack trace:

      • line 381 of /lib/dml/moodle_database.php: dml_write_exception thrown
      • line 227 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
      • line 768 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
      • line 821 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->insert_record_raw()
      • line 670 of /lib/file/file_storage.php: call to pgsql_native_moodle_database->insert_record()
      • line 355 of /lib/file/file_info_stored.php: call to file_storage->create_file_from_pathname()
      • line 99 of /files/index.php: call to file_info_stored->create_file_from_pathname()

      There should be an option to overwrite the old content because this simplifies the steps required to update an existing resource.

        Attachments

          Activity

            People

            Assignee:
            skodak Petr Skoda
            Reporter:
            ashleyholman Ashley Holman
            Tester:
            Nobody
            Participants:
            Component watchers:
            Matteo Scaramuccia, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              24/Nov/10