Skip to content
Snippets Groups Projects
Verified Commit 73e72113 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Fix album cover migration crash with cover not found on disk

parent 0aa03af3
No related branches found
No related tags found
No related merge requests found
......@@ -15,11 +15,14 @@ def create_attachments(apps, schema_editor):
return "image/jpeg"
for album in Album.objects.filter(attachment_cover=None).exclude(cover="").exclude(cover=None):
album_attachment_mapping[album] = Attachment(
file=album.cover,
size=album.cover.size,
mimetype=get_mimetype(album.cover.path),
)
try:
album_attachment_mapping[album] = Attachment(
file=album.cover,
size=album.cover.size,
mimetype=get_mimetype(album.cover.path),
)
except FileNotFoundError:
print('Skipping missing cover file {}'.format(album.cover.path))
Attachment.objects.bulk_create(album_attachment_mapping.values(), batch_size=2000)
# map each attachment to the corresponding album
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment