Ticket #78 (closed defect: fixed)

Opened 3 years ago

Last modified 7 months ago

Filename problem when using import

Reported by: huqaster@… Owned by: mike
Priority: normal Milestone: 1.0
Component: Administration Version: 1.0b2
Severity: normal Keywords: filename
Cc: huqaster@…

Description

I have several directories to sort pictures. Normally digital cameras use the same filename prefix and just add numbers for filenames. I'm not sure if this is a bug but whenever I try to import files with the same filename it shows the pictures of files that have already been imported with the same filename. Tried searching the tickets for anything related only found "try to find a new filename, if the uploaded image already exists" was wondering if this could fall as a fix for the issue?

Change History

Changed 3 years ago by mike

Maybe your browser is just caching the images? Since the images have the same name, the import thumbnails will have the same name too. Plogger deletes import thumbnails after it uses them, so this shouldn't be an issue unless your trying to import several files with the same name simultaneously. Does it actually import the same files?

Changed 3 years ago by anti

  • cc huqaster@… added

I can only reproduce this if I have the following directory structure under the "uploads" directory.

dir1/test1.jpg dir2/test1.jpg

where both images are actually different files, but have the exact same name. In which case both images have the same thumbnail allthough they shouldn't

Reporter, is this what you had in mind or are you experiencing a different problem?

Changed 3 years ago by huqaster@…

That is exactly what is happening.. So you have to have all different filenames even if the files would be located on different directories. Thanks for the reply

Changed 3 years ago by mike

  • status changed from new to closed
  • resolution set to wontfix

Not really a problem if you ask me..

Changed 3 years ago by anonymous

  • status changed from closed to reopened
  • resolution wontfix deleted
  • severity changed from major to normal

Even though this is set to "won't fix", I think it should be noted in the documentation so that users are aware of the problem and that ALL images uploaded to the /uploads/ need to have a unique filename, even across multiple directories. I don't think the fix for this would be very difficult at all, and actually only serve to improve the product. I will take a look at this myself and maybe we can have the solution submitted to the core anyway?

Changed 7 months ago by sidtheduck

  • status changed from reopened to closed
  • resolution set to fixed

Fixed in r537.

New code uses the md5 file key of uploaded files as a unique id for thumb prefix (import-md5key-filename). This may be a little messy with the 32 character prefix for the filenames, but at the moment I couldn't think of an easier way to create unique names for import thumbs. If someone thinks of something better, we can re-visit or re-open the ticket.

Changed 7 months ago by anonymous

Honestly I think you could get away with doing a string length trim on the md5 hash to 8 characters. Since people will be importing 10 - 50 pictures most of the time, and 100's in the worst case... there is a microscopic chance of collision inside the hash namespace.

Changed 7 months ago by sidtheduck

Going along with this, should I trim it down to just 2 characters (first 2 or something like 1st and 8th character)? The numbers only need to be unique for filenames that are already named exactly the same but in different subfolders in the uploads directory. I don't know the probability of filenames in separate folders having the same intro characters while using an md5 hash? Anyone else have some light to shed on this?

Changed 7 months ago by sidtheduck

or . . . (another thought), I could use the directory name for the prefix as well (files located directly in the uploads folder wouldn't have this prefix).

Changed 7 months ago by sidtheduck

I updated the code to truncate the md5 hash to the first 2 characters. I think this should be unique enough for the few instances where filenames are the same in different subfolders.

Note: See TracTickets for help on using tickets.