From 6063bf6f2a396de023eee78e14a7ce66ce6290a8 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sat, 21 Dec 2019 20:21:35 -0500 Subject: [PATCH] Don't crash when a texture is on a disconnected HDD. --- korman/exporter/image.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/korman/exporter/image.py b/korman/exporter/image.py index 926ba88..cf5ac5c 100644 --- a/korman/exporter/image.py +++ b/korman/exporter/image.py @@ -143,12 +143,17 @@ class ImageCache: # the string "//". There isn't much we can do with that, unless the user # happens to have an unpacked copy lying around somewheres... path = Path(bl_image.filepath_from_user()) - if path.is_file(): - cached_image.modify_time = path.stat().st_mtime - if cached_image.export_time and cached_image.export_time < cached_image.modify_time: - return None - else: - cached_image.modify_time = 0 + try: + exists = path.is_file() + except OSError: + exists = False + finally: + if exists: + cached_image.modify_time = path.stat().st_mtime + if cached_image.export_time and cached_image.export_time < cached_image.modify_time: + return None + else: + cached_image.modify_time = 0 # ensure the data has been loaded from the cache if cached_image.image_data is None: