Fix handling and logging of thumbnail save failures

This commit is contained in:
Olli 2026-01-10 16:04:43 +01:00
commit 0a109bc886
2 changed files with 9 additions and 3 deletions

View file

@ -341,8 +341,8 @@ class LibraryPanel(Adw.Bin):
except client.CommandException: except client.CommandException:
# Exception is handled by client # Exception is handled by client
pass pass
except Exception as e: except Exception:
self._logger.exception("Failed to load albumart", e) self._logger.exception("Failed to load albumart")
if pixbuf is None: if pixbuf is None:
icon = self._get_default_icon(self._item_size, self._item_size) icon = self._get_default_icon(self._item_size, self._item_size)
grid_item.set_icon(icon) grid_item.set_icon(icon)

View file

@ -3,6 +3,7 @@
import gi import gi
import hashlib import hashlib
import locale import locale
import logging
import os import os
gi.require_version('Gtk', '4.0') gi.require_version('Gtk', '4.0')
@ -37,7 +38,12 @@ class Utils:
if pixbuf is not None: if pixbuf is not None:
pixbuf = pixbuf.scale_simple(size, size, pixbuf = pixbuf.scale_simple(size, size,
GdkPixbuf.InterpType.HYPER) GdkPixbuf.InterpType.HYPER)
pixbuf.savev(cache_url, 'jpeg', [], []) try:
pixbuf.savev(cache_url, 'jpeg', [], [])
except Exception as e:
logger = logging.getLogger(__name__)
logger.warning("Failed to save thumbnail for album\"%s\": "
"%s", album.get_title(), e)
return pixbuf return pixbuf
@staticmethod @staticmethod