Fix generate thumbnail task messages, don't load thumbnails when the cache file has been deleted

This commit is contained in:
mmonkey 2020-12-24 03:00:26 -06:00
parent 242a2767a1
commit eef21759cd
2 changed files with 5 additions and 1 deletions

View File

@ -536,9 +536,13 @@ def delete_book(book, calibrepath, book_format):
def get_thumbnails_for_books(books):
books_with_covers = list(filter(lambda b: b.has_cover, books))
book_ids = list(map(lambda b: b.id, books_with_covers))
cache = fs.FileSystem()
thumbnail_files = cache.list_cache_files(fs.CACHE_TYPE_THUMBNAILS)
return ub.session\
.query(ub.Thumbnail)\
.filter(ub.Thumbnail.book_id.in_(book_ids))\
.filter(ub.Thumbnail.filename.in_(thumbnail_files))\
.filter(ub.Thumbnail.expiration > datetime.utcnow())\
.all()

View File

@ -75,7 +75,7 @@ class TaskGenerateCoverThumbnails(CalibreTask):
else:
self.create_book_thumbnail(book, resolution)
self.message(u'Generating cover thumbnail {0} of {1}'.format(i, count))
self.message = u'Generating cover thumbnail {0} of {1}'.format(i + 1, count)
self.progress = (1.0 / count) * i
self._handleSuccess()