From 04409eb4bd73a4fbd380cb9f6ea48fb6d6abc578 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 1 Oct 2011 10:59:22 -0600 Subject: [PATCH] Catalog generation: Handle a corrupted thumbnail cache. --- src/calibre/library/catalog.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/calibre/library/catalog.py b/src/calibre/library/catalog.py index 1aa114762f..53432af7b7 100644 --- a/src/calibre/library/catalog.py +++ b/src/calibre/library/catalog.py @@ -1059,11 +1059,15 @@ class EPUB_MOBI(CatalogPlugin): with ZipFile(self.__archive_path, mode='w') as zfw: zfw.writestr("Catalog Thumbs Archive",'') else: - with ZipFile(self.__archive_path, mode='r') as zfr: - try: - cached_thumb_width = zfr.read('thumb_width') - except: - cached_thumb_width = "-1" + try: + with ZipFile(self.__archive_path, mode='r') as zfr: + try: + cached_thumb_width = zfr.read('thumb_width') + except: + cached_thumb_width = "-1" + except: + os.remove(self.__archive_path) + cached_thumb_width = '-1' if float(cached_thumb_width) != float(self.opts.thumb_width): self.opts.log.warning(" invalidating cache at '%s'" % self.__archive_path)