Currently when an album is deleted, the Source objects (from django-thumbnails) of its photos aren't deleted. Then, if an album with the same name is uploaded again, we get IntegrityErrors when trying to create photos with the same filenames that already existed.
How to reproduce
Upload album
Delete it
Upload the same album again
Expected behaviour
The Source's are deleted, so there is no integrityerror.
This issue would be solved by making photos filenames be uuid's (#3442), and just fixing this single issue won't fix all problems we have with reuploading an album, as there is another problem:
Reuploading different photos with the same name does not invalidate the cloudfront cache. So If we do that within 24 hours, facedetection would likely analyze the wrong (stale) cached files, and they would also show up to users. So we also need to either make the filenames unique, or implement cloudfront cache invalidation. Clearly, unique filenames are the easier way to go.
I expect just overriding Album.delete() to call Photo.delete() for all photos (instead of relying on cascade deletion that probably doesn't call Photo.delete()) would fix this. If so, this is easy and fun.
Describe the bug
Currently when an album is deleted, the Source objects (from django-thumbnails) of its photos aren't deleted. Then, if an album with the same name is uploaded again, we get IntegrityErrors when trying to create photos with the same filenames that already existed.
How to reproduce
Expected behaviour
The Source's are deleted, so there is no integrityerror.
Additional context
https://thalia.sentry.io/issues/4543169553/events/239a90e83abd437e9d7116b45ec30b9a/
This issue would be solved by making photos filenames be uuid's (#3442), and just fixing this single issue won't fix all problems we have with reuploading an album, as there is another problem: Reuploading different photos with the same name does not invalidate the cloudfront cache. So If we do that within 24 hours, facedetection would likely analyze the wrong (stale) cached files, and they would also show up to users. So we also need to either make the filenames unique, or implement cloudfront cache invalidation. Clearly, unique filenames are the easier way to go.