This commit is contained in:
Kovid Goyal 2023-09-23 08:29:14 +05:30
parent 807ba2fe8b
commit a2e06b5132
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 3 deletions

View File

@ -197,10 +197,9 @@ class Adder(QObject):
def extract(source): def extract(source):
tdir = tempfile.mkdtemp(suffix='_archive', dir=self.tdir) tdir = tempfile.mkdtemp(suffix='_archive', dir=self.tdir)
if source.lower().endswith('.zip'): if source.lower().endswith('.zip'):
from calibre.utils.zipfile import ZipFile from calibre.utils.zipfile import extractall
try: try:
with ZipFile(source) as zf: extractall(source, tdir)
zf.extractall(tdir)
except Exception: except Exception:
prints('Corrupt ZIP file, trying to use local headers') prints('Corrupt ZIP file, trying to use local headers')
from calibre.utils.localunzip import extractall from calibre.utils.localunzip import extractall

View File

@ -1624,6 +1624,11 @@ class PyZipFile(ZipFile):
return (fname, archivename) return (fname, archivename)
def extractall(source, dest):
with ZipFile(source) as zf:
zf.extractall(dest)
def main(args=None): def main(args=None):
import textwrap import textwrap
USAGE=textwrap.dedent("""\ USAGE=textwrap.dedent("""\