From 07fdff36a459a6aa72fc051b7f6075957d3a81b6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 6 Feb 2014 19:03:50 +0530 Subject: [PATCH] Edit Book: Fix another bug in the save/close/re-open edit cycle for AZW3 that could cause images/fonts to get mixed up. Fixes #1276726 [Private bug](https://bugs.launchpad.net/calibre/+bug/1276726) --- src/calibre/ebooks/mobi/reader/mobi8.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/calibre/ebooks/mobi/reader/mobi8.py b/src/calibre/ebooks/mobi/reader/mobi8.py index 734ba17abe..5cb3229364 100644 --- a/src/calibre/ebooks/mobi/reader/mobi8.py +++ b/src/calibre/ebooks/mobi/reader/mobi8.py @@ -415,18 +415,17 @@ class Mobi8Reader(object): if font['encrypted']: self.encrypted_fonts.append(href) else: - if len(data) == len(PLACEHOLDER_GIF) and data == PLACEHOLDER_GIF: - continue - imgtype = what(None, data) - if imgtype is None: - from calibre.utils.magick.draw import identify_data - try: - imgtype = identify_data(data)[2] - except Exception: - imgtype = 'unknown' - href = 'images/%05d.%s'%(fname_idx, imgtype) - with open(href.replace('/', os.sep), 'wb') as f: - f.write(data) + if not (len(data) == len(PLACEHOLDER_GIF) and data == PLACEHOLDER_GIF): + imgtype = what(None, data) + if imgtype is None: + from calibre.utils.magick.draw import identify_data + try: + imgtype = identify_data(data)[2] + except Exception: + imgtype = 'unknown' + href = 'images/%05d.%s'%(fname_idx, imgtype) + with open(href.replace('/', os.sep), 'wb') as f: + f.write(data) resource_map.append(href)