diff --git a/src/calibre/ebooks/oeb/polish/container.py b/src/calibre/ebooks/oeb/polish/container.py index 4c0bda3fd6..809056b971 100644 --- a/src/calibre/ebooks/oeb/polish/container.py +++ b/src/calibre/ebooks/oeb/polish/container.py @@ -525,6 +525,11 @@ class Container(ContainerBase): # {{{ ''' Return True iff a file with the same canonical name as that specified exists. Unlike :meth:`exists` this method is always case-sensitive. ''' return name and name in self.name_path_map + def has_name_and_is_not_empty(self, name): + if not self.has_name(name): + return False + return os.path.getsize(self.name_path_map[name]) > 0 + def has_name_case_insensitive(self, name): if not name: return False diff --git a/src/calibre/srv/render_book.py b/src/calibre/srv/render_book.py index 30aae369a9..95b1b7a9ab 100644 --- a/src/calibre/srv/render_book.py +++ b/src/calibre/srv/render_book.py @@ -176,11 +176,13 @@ class Container(ContainerBase): log = log or default_log book_fmt, opfpath, input_fmt = extract_book(path_to_ebook, tdir, log=log) ContainerBase.__init__(self, tdir, opfpath, log) + # We do not add zero byte sized files as the IndexedDB API in the + # browser has no good way to distinguish between zero byte files and + # load failures. excluded_names = { name for name, mt in self.mime_map.iteritems() if name == self.opf_name or mt == guess_type('a.ncx') or name.startswith('META-INF/') or - name == 'mimetype' - } + name == 'mimetype' or not self.has_name_and_is_not_empty(name)} raster_cover_name, titlepage_name = self.create_cover_page(input_fmt.lower()) toc = get_toc(self).to_dict(count()) spine = [name for name, is_linear in self.spine_names] @@ -319,7 +321,7 @@ class Container(ContainerBase): url, frag = purl.path, purl.fragment name = self.href_to_name(url, base) if name: - if self.has_name(name): + if self.has_name_and_is_not_empty(name): frag = urlunquote(frag) url = resource_template.format(encode_url(name, frag)) else: