It seems like the code to handle images that already exist on the server is not implemented.
The Drupal Image module has a nice solution to this by creating images with _0, _1, etc attached to the end of their filenames. Maybe something like this could be implemented for image_pub?
Comments
Comment #1
kitt commentedThere are two "FIXME" notes in the code where this error should be fixed.
A first pass, not tested fully, and not tested with organic groups, but working in limited testing (unsure if I did the diff the correct direction, either, but you get the idea):
228,229c228,229
< if (file_exists(file_directory_temp() . '/' . $filename)) {
< // FIXME either rename or throw an error;
---
> if (file_exists(_image_filename($filename))) {
> $filename = file_create_filename($filename, variable_get('image_default_path', 'images'));
232c232
< // FIXME throw an error;
---
> return array('success' => FALSE, 'reason' => 'File upload error. Could not move uploaded file.');
Comment #2
will kirchheimerCould you supply a file name for locating this code?
Thanks
Comment #3
globo commentedI've tried it with drupal 5.1 and the module posted in http://drupal.org/node/70841.
Same problem. If two images have the same filename they are simply overwriten.
I guess there are two ways to solve that issue:
1. Append some kind of unique identifier to the filename. I.e. Timestamp+Filename+EXTension
and/or
2. Creating a subdirectory for each textonomy (category) and placing the images in their appropriate folder. Just like it's done in gallery2
I'd prefer the later. That however would probably be something that the gallery.module would have to handle.
Comment #4
bwynants commentedadded these changes to the zip file http://www.goju-ryu.be/image_pub.zip, however I was not able to reproduce the duplicate names....
I also added a change to mate it work fine with the Aperture exporter (ApertureToGallery) http://www.apertureplugins.com/
Comment #5
egfrith commentedThe patch at #323160: Use forms api to create image node should have fixed this. Please post here if not.