Error handling
This commit is contained in:
@@ -251,11 +251,11 @@ class DetailsWindow(Adw.Window):
|
|||||||
except GLib.GError:
|
except GLib.GError:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def resize():
|
||||||
|
if cover := resize_cover(path):
|
||||||
|
self.game_cover.new_cover(cover)
|
||||||
self.cover_button_delete_revealer.set_reveal_child(True)
|
self.cover_button_delete_revealer.set_reveal_child(True)
|
||||||
self.cover_changed = True
|
self.cover_changed = True
|
||||||
|
|
||||||
def resize():
|
|
||||||
self.game_cover.new_cover(resize_cover(path))
|
|
||||||
self.toggle_loading()
|
self.toggle_loading()
|
||||||
|
|
||||||
self.toggle_loading()
|
self.toggle_loading()
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ from pathlib import Path
|
|||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
|
|
||||||
from gi.repository import Gio
|
from gi.repository import Gio
|
||||||
from PIL import Image, ImageSequence
|
from PIL import Image, ImageSequence, UnidentifiedImageError
|
||||||
|
|
||||||
from src import shared
|
from src import shared
|
||||||
|
|
||||||
@@ -35,6 +35,7 @@ def resize_cover(cover_path=None, pixbuf=None):
|
|||||||
cover_path = Path(Gio.File.new_tmp("XXXXXX.tiff")[0].get_path())
|
cover_path = Path(Gio.File.new_tmp("XXXXXX.tiff")[0].get_path())
|
||||||
pixbuf.savev(str(cover_path), "tiff", ["compression"], ["1"])
|
pixbuf.savev(str(cover_path), "tiff", ["compression"], ["1"])
|
||||||
|
|
||||||
|
try:
|
||||||
with Image.open(cover_path) as image:
|
with Image.open(cover_path) as image:
|
||||||
if getattr(image, "is_animated", False):
|
if getattr(image, "is_animated", False):
|
||||||
frames = tuple(
|
frames = tuple(
|
||||||
@@ -61,6 +62,8 @@ def resize_cover(cover_path=None, pixbuf=None):
|
|||||||
if shared.schema.get_boolean("high-quality-images")
|
if shared.schema.get_boolean("high-quality-images")
|
||||||
else "webp",
|
else "webp",
|
||||||
)
|
)
|
||||||
|
except UnidentifiedImageError:
|
||||||
|
return None
|
||||||
|
|
||||||
return tmp_path
|
return tmp_path
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user