From 5504e9fdf9f754b72cfc67f1f58e1ab4b3d5832c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 7 Apr 2025 08:50:15 +0530 Subject: [PATCH] Switch to a map based approach --- src/calibre/utils/zipfile.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/calibre/utils/zipfile.py b/src/calibre/utils/zipfile.py index 522f2fc938..edb8d9b69b 100644 --- a/src/calibre/utils/zipfile.py +++ b/src/calibre/utils/zipfile.py @@ -1113,10 +1113,15 @@ class ZipFile: # Kovid: Extract longer names first, just in case the zip file has # an entry for a directory without a trailing slash members.sort(key=len, reverse=True) - zimembers = tuple(map(self.getinfo, members)) + args = [] + for name in members: + zi = self.getinfo(name) + dest = self._get_targetpath(zi, path) + args.append((zi, dest, pwd)) - for zipinfo in zimembers: - self._extract_member(zipinfo, path, pwd) + def do_one(a): + return self._extract_member_to(*a) + tuple(map(do_one, args)) def _get_targetpath(self, member: ZipInfo, targetpath: str) -> str: # build the destination pathname, replacing