diff --git a/src/calibre/ebooks/lrf/epub/convert_from.py b/src/calibre/ebooks/lrf/epub/convert_from.py index 701681243e..110946824b 100644 --- a/src/calibre/ebooks/lrf/epub/convert_from.py +++ b/src/calibre/ebooks/lrf/epub/convert_from.py @@ -8,7 +8,7 @@ from calibre.ebooks import ConversionError from calibre.ebooks.lrf.html.convert_from import process_file as html_process_file from calibre.ebooks.metadata.opf import OPF from calibre.ebooks.metadata.epub import OCFDirReader -from calibre.libunzip import extract as zip_extract +from calibre.utils.zipfile import ZipFile from calibre import __appname__, setup_cli_handlers @@ -26,7 +26,7 @@ def generate_html(pathtoepub, logger): tdir = mkdtemp(prefix=__appname__+'_') os.rmdir(tdir) try: - zip_extract(pathtoepub, tdir) + ZipFile(pathtoepub).extractall(tdir) except: if os.path.exists(tdir) and os.path.isdir(tdir): shutil.rmtree(tdir) diff --git a/src/calibre/utils/zipfile.py b/src/calibre/utils/zipfile.py index ff31210444..ff9eacf158 100644 --- a/src/calibre/utils/zipfile.py +++ b/src/calibre/utils/zipfile.py @@ -1028,7 +1028,7 @@ class ZipFile: # Create all upper directories if necessary. upperdirs = os.path.dirname(targetpath) - if upperdirs and not os.path.isdir(upperdirs): + if upperdirs and os.path.exists(upperdirs) and not os.path.isdir(upperdirs): os.unlink(upperdirs) if upperdirs and not os.path.exists(upperdirs): os.makedirs(upperdirs)