feat(db): handle PIL errors opening images gracefully

For example, if PIL tries to open a *really* big image, it will raise an exception to prevent reading a huge object into memory.
This commit is contained in:
psychedelicious 2023-12-18 18:02:31 +11:00
parent aefa828237
commit b6ed4ba559

View File

@ -159,6 +159,9 @@ class Migration2Callback:
except ImageFileNotFoundException: except ImageFileNotFoundException:
self._logger.warning(f"Image {image_name} not found, skipping") self._logger.warning(f"Image {image_name} not found, skipping")
continue continue
except Exception as e:
self._logger.warning(f"Error while checking image {image_name}, skipping: {e}")
continue
if "invokeai_workflow" in pil_image.info: if "invokeai_workflow" in pil_image.info:
try: try:
UnsafeWorkflowWithVersionValidator.validate_json(pil_image.info.get("invokeai_workflow", "")) UnsafeWorkflowWithVersionValidator.validate_json(pil_image.info.get("invokeai_workflow", ""))