From 2ea7fd0c52103e8d66628222ae8ceafc8ee061ff Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 29 Dec 2017 11:09:24 +0530 Subject: [PATCH] Edit Book: Refuse to save EPUB files that have missing container.xml files. See #1740460 (Edit Book feature results in error after previously editing successfully) --- src/calibre/ebooks/oeb/polish/container.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/calibre/ebooks/oeb/polish/container.py b/src/calibre/ebooks/oeb/polish/container.py index ceecb12153..ef43d802a1 100644 --- a/src/calibre/ebooks/oeb/polish/container.py +++ b/src/calibre/ebooks/oeb/polish/container.py @@ -1296,6 +1296,10 @@ class EpubContainer(Container): def commit(self, outpath=None, keep_parsed=False): super(EpubContainer, self).commit(keep_parsed=keep_parsed) + container_path = join(self.root, 'META-INF', 'container.xml') + if not exists(container_path): + raise InvalidEpub('No META-INF/container.xml in EPUB, this typically happens if the temporary files calibre' + ' is using are deleted by some other program while calibre is running') restore_fonts = {} for name in self.obfuscated_fonts: if name not in self.name_path_map: