mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Catch error if invalid image is uploaded
This commit is contained in:
parent
15678f789c
commit
5f19f534fc
@ -7,6 +7,7 @@ from django.db.utils import OperationalError, ProgrammingError
|
|||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
from PIL import UnidentifiedImageError
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -44,9 +45,11 @@ class PartConfig(AppConfig):
|
|||||||
try:
|
try:
|
||||||
part.image.render_variations(replace=False)
|
part.image.render_variations(replace=False)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
logger.warning("Image file missing")
|
logger.warning(f"Image file '{part.image}' missing")
|
||||||
part.image = None
|
part.image = None
|
||||||
part.save()
|
part.save()
|
||||||
|
except UnidentifiedImageError:
|
||||||
|
logger.warning(f"Image file '{part.image}' is invalid")
|
||||||
except (OperationalError, ProgrammingError):
|
except (OperationalError, ProgrammingError):
|
||||||
# Exception if the database has not been migrated yet
|
# Exception if the database has not been migrated yet
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user