EPUB Input: Fix bug in unzipping EPUB files that have been zipped in depth first order. Fixes #6127 (Cannot open or convert News Feed "books" - problems with path in Windows)

This commit is contained in:
Kovid Goyal 2010-07-09 10:45:07 -06:00
parent ec607dc596
commit c8438cc296
2 changed files with 11 additions and 3 deletions

View File

@ -213,7 +213,7 @@ class KINDLE_DX(KINDLE2):
PRODUCT_ID = [0x0003]
BCD = [0x0100]
class Bookmark():
class Bookmark(): # {{{
'''
A simple class fetching bookmark data
Kindle-specific
@ -517,3 +517,6 @@ class Bookmark():
else:
print "unsupported bookmark_extension: %s" % self.bookmark_extension
# }}}

View File

@ -1071,8 +1071,13 @@ class ZipFile:
# Create all upper directories if necessary.
upperdirs = os.path.dirname(targetpath)
if upperdirs and os.path.exists(upperdirs) and not os.path.isdir(upperdirs):
os.unlink(upperdirs)
while upperdirs:
if os.path.exists(upperdirs):
if os.path.isdir(upperdirs):
break
os.remove(upperdirs)
upperdirs = os.path.dirname(upperdirs)
upperdirs = os.path.dirname(targetpath)
if upperdirs and not os.path.exists(upperdirs):
os.makedirs(upperdirs)