espen / balder

Balder - Open source Ruby on Rails photo gallery
http://balderapp.com
MIT License
263 stars 97 forks source link

/photos/scan creates duplicates #38

Open nullmedium opened 11 years ago

nullmedium commented 11 years ago

I moved some images on my server from one old gallery to the uploads folder into a new album. When I called /photos/scan to import the new photos, the scan algorithm created new records for the previous images within the "photos" table.

espen commented 11 years ago

The script was supposed to ignore existing photos. It uses 'Photo.find_or_initialize_by_path(path)'. I guess this should be changed as path is not really used for photos. Maybe using 'Photo.find_or_initialize_by_file(path)' would work. I assume the existing photos had a null value for path? Can you post some examples of duplicate photos? Or at least the value of 'file'.

nullmedium commented 11 years ago

When I had a look at my database the "file" column contained the absolute path to the images. The records for the photos I had uploaded earlier, had just the filename. I think, modifying the script to check for the file's basename would work.

If I get to it, I will try a development database to mess with.