diff --git a/src/calibre/utils/zipfile.py b/src/calibre/utils/zipfile.py index 02f7eac5c4..ff31210444 100644 --- a/src/calibre/utils/zipfile.py +++ b/src/calibre/utils/zipfile.py @@ -1028,11 +1028,13 @@ class ZipFile: # Create all upper directories if necessary. upperdirs = os.path.dirname(targetpath) + if upperdirs and not os.path.isdir(upperdirs): + os.unlink(upperdirs) if upperdirs and not os.path.exists(upperdirs): os.makedirs(upperdirs) - + source = self.open(member, pwd=pwd) - target = file(targetpath, "wb") + target = open(targetpath, "wb") shutil.copyfileobj(source, target) source.close() target.close()