From e4997a02e19f0e6f84cc54087840fe9c0bb67b1f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 11 Jun 2020 19:58:48 +0530 Subject: [PATCH] Edit book: Fix Check book spuriously reporting incorrect mime type warnings for fonts after upgrading a book from EPUB 2 to EPUB 3. Fixes #1882436 [Upgrade book internals from 2 to 3 causes font MIME type warningserr](https://bugs.launchpad.net/calibre/+bug/1882436) --- src/calibre/ebooks/oeb/polish/upgrade.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/oeb/polish/upgrade.py b/src/calibre/ebooks/oeb/polish/upgrade.py index ff6ff7d972..be8d1ab444 100644 --- a/src/calibre/ebooks/oeb/polish/upgrade.py +++ b/src/calibre/ebooks/oeb/polish/upgrade.py @@ -23,11 +23,14 @@ def add_properties(item, *props): def fix_font_mime_types(container): + changed = False for item in container.opf_xpath('//opf:manifest/opf:item[@href and @media-type]'): mt = item.get('media-type') or '' if mt.lower() in OEB_FONTS: name = container.href_to_name(item.get('href'), container.opf_name) item.set('media-type', container.guess_type(name)) + changed = True + return changed def collect_properties(container): @@ -125,7 +128,8 @@ def epub_2_to_3(container, report, previous_nav=None): guide.getparent().remove(guide) create_nav(container, toc, landmarks, previous_nav) container.opf.set('version', '3.0') - fix_font_mime_types(container) + if fix_font_mime_types(container): + container.refresh_mime_map() container.dirty(container.opf_name)