#7 — Uploading a file that already exists generates a vague error message

StateConfirmed
Version: 1.1
AreaFunctionality
Issue typeBug
SeverityMedium
Submitted byReinout van Rees
Submitted onJan 16, 2009
Responsible
Target release:
Return to tracker
Last modified on May 13, 2009 by Maurits van Rees
**Copied from the old tracker at p4a.org, reported by Michael Trachtman**

When uploading a file to a location where the file already exists (the filename being the piece of identifying information), user receives a vague error dialog 'Error: Error on uploading files'.

User should receive a message that indicates that the file already exists, and perhaps it should be done through Plone's status message plumbing versus a JavaScript dialog.


Couple of behavior options:

1) Ignore files that already exist, just keep uploading.
2) If a file exists, upload it again, but give it a different name (perhaps with a suffix)

Maybe the option could be admin-settable in the configlet.
Steps to reproduce:
    Upload or create an image called test.png in a folder. Then, attempt to FlashUpload an image with the same name. Error message appears.

Added byReinout van ReesonJan 16, 2009 02:36 PM
Issue state: UnconfirmedConfirmed
Added byShaun WalbridgeonApr 17, 2009 11:21 PM
I'm also having this problem, the error reported to the browser is 'Upload Error: 400'. The traceback ends with a simple enough 'BadRequest: The id "Thomson2007doso.pdf" is invalid - it is already in use.'

Perhaps it'd be best to have this default to standard Plone behavior and create 'copy_of_' prefixed files?
Added byShaun WalbridgeonApr 22, 2009 09:16 PM
I've fixed this problem by adding the id resolution code used in CopySupport (_get_id). Duplicates are named in the 'copy(n)_of_filename' fashion used elsewhere, and it successfully allows PloneFlashUpload to run through a mixed list of new and existing files.
Attached:
duplicate_filenames.patch — text/x-diff, 1 Kb
Added byMaurits van ReesonMay 13, 2009 11:10 PM
In r86014 I fixed this, inspired by Shaun's patch. I went for a variant of the Archetypes/BaseObject.py:_findUniqueId method as that is what normally gets called when adding a content item with an id that already exists. Biggest change compared to that method is: we do not rename image.jpg to image.jpg-1 but to image-1.jpg.

I see no reason why this would fail in other browsers as it is just python code on the server, but testing it with IE would probably be good. (I tested with Firefox/Linux/Flash10.)

So please mark this issue as resolved after checking that it works.

BTW, before someone gets the wrong idea: I know python, but when it comes to Javascript and Flash I am mostly clueless. :-)

No responses can be added.