several photos may share the same path #2076

Closed
opened 2026-10-05 01:05:34 +02:00 by adam · 1 comment
Owner

This is what I call the "duplicate path" issue: 2+ lines share the same images.path value.

MariaDB [pwggit]> select id, file, path, md5sum from piwigo_images order by id desc limit 3;
+-----+-------------------+-------------------------------------------------+----------------------------------+
| id  | file              | path                                            | md5sum                           |
+-----+-------------------+-------------------------------------------------+----------------------------------+
| 231 | image.png         | ./upload/2025/07/14/20250714124155-d995763d.png | d995763d1e8cb0226dd884520a9f8e7d |
| 230 | image copy.png    | ./upload/2025/07/14/20250714124154-d995763d.png | d995763d1e8cb0226dd884520a9f8e7d |
| 229 | image copy 2.png  | ./upload/2025/07/14/20250714124154-d995763d.png | d995763d1e8cb0226dd884520a9f8e7d |
+-----+-------------------+-------------------------------------------------+----------------------------------+
3 rows in set (0.001 sec)

The 3 files are identical (same md5sum). We upload them in the same batch and with the "new" option "Detect and avoid duplicates during upload" deactivated.

As we can see, photo#229 and photo#230 end up with the exact same path because they're uploade in the same second and share the same md5sum. This is a real problem because if you delete photo#229 it will generate a missing file for photo#230 😥

The same problem has caused many duplicate paths with plugin Virtualize since many files share the same date_available. Virtualize plugin has been fixed, see https://github.com/plegall/Piwigo-virtualize/commit/19276436445096ecd0a72e8516d59c33e0579a94

  • to avoid generating duplicate paths, we should introduce more randomness in the file path before writing file during upload
  • to fix the existing duplicate paths, plugin Check Uploads will get a "deduplicate" action
  • to avoid generating missing files, we should add a check during deletion : if the path is shared with another image, we should not delete the file
This is what I call the "duplicate path" issue: 2+ lines share the same `images.path` value. ``` MariaDB [pwggit]> select id, file, path, md5sum from piwigo_images order by id desc limit 3; +-----+-------------------+-------------------------------------------------+----------------------------------+ | id | file | path | md5sum | +-----+-------------------+-------------------------------------------------+----------------------------------+ | 231 | image.png | ./upload/2025/07/14/20250714124155-d995763d.png | d995763d1e8cb0226dd884520a9f8e7d | | 230 | image copy.png | ./upload/2025/07/14/20250714124154-d995763d.png | d995763d1e8cb0226dd884520a9f8e7d | | 229 | image copy 2.png | ./upload/2025/07/14/20250714124154-d995763d.png | d995763d1e8cb0226dd884520a9f8e7d | +-----+-------------------+-------------------------------------------------+----------------------------------+ 3 rows in set (0.001 sec) ``` The 3 files are identical (same `md5sum`). We upload them in the same batch and with the "new" option "Detect and avoid duplicates during upload" deactivated. As we can see, photo#229 and photo#230 end up with the exact same `path` because they're uploade in the same second and share the same `md5sum`. This is a real problem because if you delete photo#229 it will generate a missing file for photo#230 😥 The same problem has caused many duplicate paths with plugin Virtualize since many files share the same `date_available`. Virtualize plugin has been fixed, see https://github.com/plegall/Piwigo-virtualize/commit/19276436445096ecd0a72e8516d59c33e0579a94 - to avoid generating duplicate paths, we should introduce more randomness in the file path before writing file during upload - to fix the existing duplicate paths, plugin Check Uploads will get a "deduplicate" action - to avoid generating missing files, we should add a check during deletion : if the path is shared with another image, we should not delete the file <!-- github-sync-id:3228364798 -->
adam closed this issue 2026-10-05 01:05:34 +02:00
Author
Owner

to avoid generating missing files, we should add a check during deletion : if the path is shared with another image, we should not delete the file

After second thought, I won't implement this. Instead I implemented a big warning when Piwigo finds duplicate paths.

Image
> to avoid generating missing files, we should add a check during deletion : if the path is shared with another image, we should not delete the file After second thought, I won't implement this. Instead I implemented a big warning when Piwigo finds duplicate paths. <img width="798" height="542" alt="Image" src="https://github.com/user-attachments/assets/9b2d809c-8b7c-436e-bfd6-3e8f0b63960b" /> <!-- github-comment-id:3114694418 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#2076