mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add error checking for thumbnail file migration
This commit is contained in:
parent
d6d891c16f
commit
37fcb810e4
@ -31,6 +31,11 @@ class CompanyConfig(AppConfig):
|
|||||||
|
|
||||||
if not os.path.exists(loc):
|
if not os.path.exists(loc):
|
||||||
print("InvenTree: Generating thumbnail for Company '{c}'".format(c=company.name))
|
print("InvenTree: Generating thumbnail for Company '{c}'".format(c=company.name))
|
||||||
company.image.render_variations(replace=False)
|
try:
|
||||||
|
company.image.render_variations(replace=False)
|
||||||
|
except FileNotFoundError:
|
||||||
|
print("Image file missing")
|
||||||
|
company.image = None
|
||||||
|
company.save()
|
||||||
except (OperationalError, ProgrammingError):
|
except (OperationalError, ProgrammingError):
|
||||||
print("Could not generate Company thumbnails")
|
print("Could not generate Company thumbnails")
|
||||||
|
@ -30,6 +30,11 @@ class PartConfig(AppConfig):
|
|||||||
|
|
||||||
if not os.path.exists(loc):
|
if not os.path.exists(loc):
|
||||||
print("InvenTree: Generating thumbnail for Part '{p}'".format(p=part.name))
|
print("InvenTree: Generating thumbnail for Part '{p}'".format(p=part.name))
|
||||||
part.image.render_variations(replace=False)
|
try:
|
||||||
|
part.image.render_variations(replace=False)
|
||||||
|
except FileNotFoundError:
|
||||||
|
print("Image file missing")
|
||||||
|
part.image = None
|
||||||
|
part.save()
|
||||||
except (OperationalError, ProgrammingError):
|
except (OperationalError, ProgrammingError):
|
||||||
print("Could not generate Part thumbnails")
|
print("Could not generate Part thumbnails")
|
||||||
|
@ -16,7 +16,14 @@ def create_thumbnails(apps, schema_editor):
|
|||||||
for part in Part.objects.all():
|
for part in Part.objects.all():
|
||||||
# Render thumbnail for each existing Part
|
# Render thumbnail for each existing Part
|
||||||
if part.image:
|
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):
|
except (OperationalError, ProgrammingError):
|
||||||
# Migrations have not yet been applied - table does not exist
|
# Migrations have not yet been applied - table does not exist
|
||||||
print("Could not generate Part thumbnails")
|
print("Could not generate Part thumbnails")
|
||||||
|
Loading…
Reference in New Issue
Block a user