mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Catch potential error updating image that does not exist...
This commit is contained in:
parent
2fc7c3d883
commit
b8e4b58df0
@ -28,7 +28,7 @@ def schedule_task(taskname, **kwargs):
|
|||||||
try:
|
try:
|
||||||
from django_q.models import Schedule
|
from django_q.models import Schedule
|
||||||
except (AppRegistryNotReady):
|
except (AppRegistryNotReady):
|
||||||
logger.warning("Could not start background tasks - App registry not ready")
|
logger.info("Could not start background tasks - App registry not ready")
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -44,8 +44,6 @@ class CompanyConfig(AppConfig):
|
|||||||
company.image.render_variations(replace=False)
|
company.image.render_variations(replace=False)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
logger.warning(f"Image file '{company.image}' missing")
|
logger.warning(f"Image file '{company.image}' missing")
|
||||||
company.image = None
|
|
||||||
company.save()
|
|
||||||
except UnidentifiedImageError:
|
except UnidentifiedImageError:
|
||||||
logger.warning(f"Image file '{company.image}' is invalid")
|
logger.warning(f"Image file '{company.image}' is invalid")
|
||||||
except (OperationalError, ProgrammingError):
|
except (OperationalError, ProgrammingError):
|
||||||
|
@ -39,7 +39,8 @@ class PartConfig(AppConfig):
|
|||||||
logger.debug("InvenTree: Checking Part image thumbnails")
|
logger.debug("InvenTree: Checking Part image thumbnails")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for part in Part.objects.all():
|
# Only check parts which have images
|
||||||
|
for part in Part.objects.exclude(image=None):
|
||||||
if part.image:
|
if part.image:
|
||||||
url = part.image.thumbnail.name
|
url = part.image.thumbnail.name
|
||||||
loc = os.path.join(settings.MEDIA_ROOT, url)
|
loc = os.path.join(settings.MEDIA_ROOT, url)
|
||||||
@ -50,8 +51,7 @@ class PartConfig(AppConfig):
|
|||||||
part.image.render_variations(replace=False)
|
part.image.render_variations(replace=False)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
logger.warning(f"Image file '{part.image}' missing")
|
logger.warning(f"Image file '{part.image}' missing")
|
||||||
part.image = None
|
pass
|
||||||
part.save()
|
|
||||||
except UnidentifiedImageError:
|
except UnidentifiedImageError:
|
||||||
logger.warning(f"Image file '{part.image}' is invalid")
|
logger.warning(f"Image file '{part.image}' is invalid")
|
||||||
except (OperationalError, ProgrammingError):
|
except (OperationalError, ProgrammingError):
|
||||||
|
Loading…
Reference in New Issue
Block a user