When I upload a image in a node, delete it from the node and then upload it again it says:

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: /file/ajax/field_picture_flyer_1/en/0/form-XtmzIw64Wbu7-p7LGbi1BpsMQp8UCx15nZsJcdsuqIg
StatusText: n/a
ResponseText: 
Error  
Error message
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'public://flyer_picture_2.jpg' for key 2: INSERT INTO {file_managed} (uid, filename, uri, filemime, filesize, status, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6); Array
(
[:db_insert_placeholder_0] => 1
[:db_insert_placeholder_1] => flyer_picture.jpg
[:db_insert_placeholder_2] => public://flyer_picture_2.jpg
[:db_insert_placeholder_3] => image/jpeg
[:db_insert_placeholder_4] => 15277
[:db_insert_placeholder_5] => 0
[:db_insert_placeholder_6] => 1298292968
)
in drupal_write_record() (line 6776 of /home/latravia/sites/prive_frits/dev/estheticdentalteam.nl/includes/common.inc).
The website encountered an unexpected error. Please try again later.    

ReadyState: undefined

The file is uploaded and renamed, but not in the DB.

Comments

Frits1980’s picture

Priority: Normal » Critical

Ok after some more testing I thought I had the solution, but the result is even worse (Critical).

I first thought I could easily get around this by removing the old picture and saving the node then editing it again and uploading that same picture. To bad that didn't work. Issue here is that it doesn't rename if there is already a file there with the same name, it just give an Ajax error simulair as mentioned in my first post.

Next thing I tried was renaming the file before uploading it again, ofcource this did work!
But after some more uploading and looking at my website I discovered that some images are copied over by others I have been uploading. So the whole renaming process just doesn't work flawless.
And since I have about 4000 pictures to upload in multiple content types this is a critical bug!

Please give some reaction. I'm really on a deadline. I know that I can't demand anything, but it would be nice just to know that someone is looking into it.

Thank you.

catch’s picture

Title: Uploade duplicate file » Duplicate files are not renamed successfully
Version: 7.0 » 7.x-dev
Component: image system » file system

Moving this to the right component.

Can you confirm the file names are exactly the same - i.e. no difference in upper/lower case etc.

If there's a difference in case, could you post the MySQL collation being used?

bfroehle’s picture

Alan D.’s picture

Interesting. I found a similar thing in hook_date_formats() that has an unique format index in the database. Thus this:

/**
 * Implements hook_date_formats().
 */
function almanac_date_formats() {
  return array(
    // MySQL throws an error here if both are returned.
    array('type' => 'time', 'format' => 'g:i a', 'locales' => array()),
    array('type' => 'time', 'format' => 'g:i A', 'locales' => array()),
  );
}

threw a PDO exception.

EDIT
MySQL is case insensitive depending on the column collation. #1012620: Unique key on date_formats.(format|type) is problematic for case insensitive collations

dixon_’s picture

I can't reproduce this bug. Can you clarify the steps involved in more details, on how to reproduce this?

When I upload a image in a node, delete it from the node and then upload it again it says:

The steps I went through to test this:

  1. Open up the form for creating a node and start editing it
  2. Upload an image in a filefield, using the "Browse" button
  3. Remove the file by using the "Remove" button, resulting in an AJAX update of the form
  4. Upload the file again using the "Browse" button
  5. Saving the node form

Nothing wrong happens, no error messages appears. I might have misunderstood this issue, so please correct me if I'm wrong.

aspilicious’s picture

dixon did you use spaces in your name? Did you try the same name with different cases?

Insert "This is an image.png"
Remove "This is an image.png"
Insert "this is an image.png"

should work on paper.

catch’s picture

Status: Active » Postponed (maintainer needs more info)

I'm going to move this to needs more info until it's confirmed.

Frits1980’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Ok, I've done some testing on an empty site with only drupal 7 core. No problems occur.
Apparently something went wrong with my other installation of drupal. And since nobody can reproduce that I'm going to assume we will never find where it went wrong. Since the other installation has about 12 contrib modules installed and another 14 or so installed and removed I think this would be a endless story to figure out.

Thank you guys for trying to help out!

narendra0111’s picture

Issue summary: View changes

Hi,

This is clearly a bug i'm facing it now. Suppose i have processe 200 created nodes with same image name and images renamed corretly till "image_name_200". But when i procees it again the on few files renaming error occurs like "file_name_153" already exists in the "file_managed" file.
Please provide a proper solution for this one.