diff options
Diffstat (limited to 'tagit/widgets')
-rw-r--r-- | tagit/widgets/browser.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/tagit/widgets/browser.py b/tagit/widgets/browser.py index 4a254ee..1e42c9c 100644 --- a/tagit/widgets/browser.py +++ b/tagit/widgets/browser.py @@ -7,6 +7,7 @@ Author: Matthias Baumgartner, 2022 # standard imports from collections import defaultdict from functools import reduce, partial +import io import logging import math import operator @@ -421,8 +422,13 @@ class Browser(GridLayout, StorageAwareMixin, ConfigAwareMixin): # select the best fitting preview chosen = rmatcher.by_area_min(resolution, options) # open the preview file, default if no asset is available - thumb = open(chosen.get(ns.bsp.asset, default=default), 'rb') # FIXME: mb/port: asset storage - except IndexError: + thumb_data = chosen.asset(default=None) # FIXME: get all assets in one call + if thumb_data is None: + raise KeyError() + thumb = io.BytesIO(thumb_data) + + except (KeyError, IndexError): + # KeyError: # no viable resolution found thumb = open(default, 'rb') # update the image in the child widget |