2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-08-08 04:40:57 +00:00

Add error checking for thumbnail file migration

This commit is contained in:
Oliver Walters
2020-04-17 19:23:43 +10:00
parent d6d891c16f
commit 37fcb810e4
3 changed files with 20 additions and 3 deletions

View File

@@ -16,7 +16,14 @@ def create_thumbnails(apps, schema_editor):
for part in Part.objects.all():
# Render thumbnail for each existing Part
if part.image:
part.image.render_variations()
try:
part.image.render_variations()
except FileNotFoundError:
print("Missing image:", part.image())
# The image is missing, so clear the field
part.image = None
part.save()
except (OperationalError, ProgrammingError):
# Migrations have not yet been applied - table does not exist
print("Could not generate Part thumbnails")