From b8e4b58df00e8ea061412d2901eeef9ad6c05daf Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 22 Jun 2021 22:19:22 +1000 Subject: [PATCH] Catch potential error updating image that does not exist... --- InvenTree/InvenTree/tasks.py | 2 +- InvenTree/company/apps.py | 2 -- InvenTree/part/apps.py | 6 +++--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/InvenTree/InvenTree/tasks.py b/InvenTree/InvenTree/tasks.py index 4fb78cfbab..f0fe504072 100644 --- a/InvenTree/InvenTree/tasks.py +++ b/InvenTree/InvenTree/tasks.py @@ -28,7 +28,7 @@ def schedule_task(taskname, **kwargs): try: from django_q.models import Schedule 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 try: diff --git a/InvenTree/company/apps.py b/InvenTree/company/apps.py index 4366f63434..76798c5ad4 100644 --- a/InvenTree/company/apps.py +++ b/InvenTree/company/apps.py @@ -44,8 +44,6 @@ class CompanyConfig(AppConfig): company.image.render_variations(replace=False) except FileNotFoundError: logger.warning(f"Image file '{company.image}' missing") - company.image = None - company.save() except UnidentifiedImageError: logger.warning(f"Image file '{company.image}' is invalid") except (OperationalError, ProgrammingError): diff --git a/InvenTree/part/apps.py b/InvenTree/part/apps.py index 1b233bccac..0c57e2c1ab 100644 --- a/InvenTree/part/apps.py +++ b/InvenTree/part/apps.py @@ -39,7 +39,8 @@ class PartConfig(AppConfig): logger.debug("InvenTree: Checking Part image thumbnails") try: - for part in Part.objects.all(): + # Only check parts which have images + for part in Part.objects.exclude(image=None): if part.image: url = part.image.thumbnail.name loc = os.path.join(settings.MEDIA_ROOT, url) @@ -50,8 +51,7 @@ class PartConfig(AppConfig): part.image.render_variations(replace=False) except FileNotFoundError: logger.warning(f"Image file '{part.image}' missing") - part.image = None - part.save() + pass except UnidentifiedImageError: logger.warning(f"Image file '{part.image}' is invalid") except (OperationalError, ProgrammingError):