This commit is contained in:
Eli Lipsitz 2024-09-27 20:37:51 -03:00 committed by GitHub
commit 18fc5729f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -434,6 +434,14 @@ def unpack(filename, destination): # type: (str, str) -> None
# https://bugs.python.org/issue17153 # https://bugs.python.org/issue17153
destination = str(destination) destination = str(destination)
archive_obj.extractall(destination) archive_obj.extractall(destination)
# ZipFile on Unix systems does not preserve file permissions while extracting it
# We need to reset the permissions afterward
if sys.platform != 'win32' and filename.endswith('zip') and isinstance(archive_obj, ZipFile):
for file_info in archive_obj.infolist():
extracted_file = os.path.join(destination, file_info.filename)
extracted_permissions = file_info.external_attr >> 16 & 0o777 # Extract Unix permissions
if os.path.exists(extracted_file):
os.chmod(extracted_file, extracted_permissions)
def splittype(url): # type: (str) -> Tuple[Optional[str], str] def splittype(url): # type: (str) -> Tuple[Optional[str], str]