From 47a11435703ff9d36d4af6a73cee2c946d8c05ce Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 17 Mar 2021 11:55:51 +1100 Subject: [PATCH] Catch error when generating company thumbnail images --- InvenTree/company/apps.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/InvenTree/company/apps.py b/InvenTree/company/apps.py index 2777425ab4..3fa3197183 100644 --- a/InvenTree/company/apps.py +++ b/InvenTree/company/apps.py @@ -7,6 +7,7 @@ from django.apps import AppConfig from django.db.utils import OperationalError, ProgrammingError from django.conf import settings +from PIL import UnidentifiedImageError logger = logging.getLogger(__name__) @@ -38,9 +39,11 @@ class CompanyConfig(AppConfig): try: company.image.render_variations(replace=False) except FileNotFoundError: - logger.warning("Image file missing") + 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): # Getting here probably meant the database was in test mode pass