mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
E-book viewer: Fix some links not being processed correctly for very large EPUB files with many internal HTML files.
This commit is contained in:
parent
8c06e89aaf
commit
3fd1bc2df7
@ -548,10 +548,16 @@ class Container(ContainerBase): # {{{
|
||||
return name and name in self.name_path_map
|
||||
|
||||
def has_name_and_is_not_empty(self, name):
|
||||
if not self.has_name(name):
|
||||
path = self.name_path_map.get(name)
|
||||
if not path:
|
||||
return False
|
||||
try:
|
||||
return os.path.getsize(self.name_path_map[name]) > 0
|
||||
if (sz := os.path.getsize(path)) == 0:
|
||||
# this can happen when the directory entry is not flushed (which happens during fast EPUB extraction), so
|
||||
# open the file and check to be sure.
|
||||
with open(path) as f:
|
||||
sz = f.seek(0, os.SEEK_END)
|
||||
return sz > 0
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user