Skip to content

Commit

Permalink
Handle OSError when opening/saving images with PIL
Browse files Browse the repository at this point in the history
Decoding/encoding errors usually raise an OSError.
  • Loading branch information
City-busz committed Nov 2, 2024
1 parent fa86a25 commit 236568e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cartridges/details_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def thread_func() -> None:
with Image.open(path) as image:
if getattr(image, "is_animated", False):
new_path = convert_cover(path)
except UnidentifiedImageError:
except (UnidentifiedImageError, OSError):
pass

if new_path:
Expand Down
2 changes: 1 addition & 1 deletion cartridges/utils/save_cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def convert_cover(
if shared.schema.get_boolean("high-quality-images")
else shared.TIFF_COMPRESSION,
)
except UnidentifiedImageError:
except (UnidentifiedImageError, OSError):
try:
Gdk.Texture.new_from_filename(str(cover_path)).save_to_tiff(
tmp_path := Gio.File.new_tmp("XXXXXX.tiff")[0].get_path()
Expand Down

0 comments on commit 236568e

Please sign in to comment.