From eef21759cd56c28560ee2007726fab18c8595df5 Mon Sep 17 00:00:00 2001 From: mmonkey Date: Thu, 24 Dec 2020 03:00:26 -0600 Subject: [PATCH] Fix generate thumbnail task messages, don't load thumbnails when the cache file has been deleted --- cps/helper.py | 4 ++++ cps/tasks/thumbnail.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cps/helper.py b/cps/helper.py index c33a69e1..add1b067 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -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() diff --git a/cps/tasks/thumbnail.py b/cps/tasks/thumbnail.py index e9df170e..70ddc06b 100644 --- a/cps/tasks/thumbnail.py +++ b/cps/tasks/thumbnail.py @@ -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()