mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Small change to commit d84b1e2 to be a little safer.
This commit is contained in:
parent
d84b1e2009
commit
cfc14e774f
@ -972,6 +972,7 @@ class GridView(QListView):
|
||||
cache_valid = None
|
||||
else:
|
||||
# A cover is in the cache. Check whether it is up to date.
|
||||
# Note that if tcdata is not None then it is already a PIL image.
|
||||
has_cover, tcdata, timestamp = db.new_api.cover_or_cache(book_id, timestamp,
|
||||
as_what='pil_image')
|
||||
if has_cover:
|
||||
@ -1012,12 +1013,6 @@ class GridView(QListView):
|
||||
if cover_tuple.has_cover:
|
||||
# cdata contains either the resized thumbnail, the full cover.jpg
|
||||
# rendered as a PIL image, or None if cover.jpg isn't valid
|
||||
if cdata.getbbox() is None and cover_tuple.cache_valid:
|
||||
# Something wrong with the cover data in the cache. Remove it
|
||||
# from the cache and queue it to render again.
|
||||
tc.invalidate((book_id,))
|
||||
self.render_queue.put(book_id)
|
||||
return None
|
||||
if not cover_tuple.cache_valid:
|
||||
# The cover isn't in the cache, is stale, or isn't a valid
|
||||
# image. We might have the image from cover.jpg, in which case
|
||||
@ -1052,6 +1047,20 @@ class GridView(QListView):
|
||||
# The cover data isn't valid. Remove it from the cache
|
||||
tc.invalidate((book_id,))
|
||||
else:
|
||||
# Test to see if there is something wrong with the cover data in
|
||||
# the cache. If so, remove it from the cache and queue it to
|
||||
# render again. It isn't clear that this can ever happen. One
|
||||
# possibility is if different versions of calibre are used
|
||||
# interchangeably.
|
||||
def getbbox(img):
|
||||
try:
|
||||
return img.getbbox()
|
||||
except Exception:
|
||||
return None
|
||||
if getbbox(cdata) is None:
|
||||
tc.invalidate((book_id,))
|
||||
self.render_queue.put(book_id)
|
||||
return None
|
||||
# The data from the cover cache is valid and is already a thumb.
|
||||
thumb = cdata
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user