Skip to content

Commit

Permalink
Extract file mode from ZIP file
Browse files Browse the repository at this point in the history
This commit adds calling "chmod" for extracted files to restore possible executable flag. Otherwise shipped binaries can't be executed on Linux/MacOS.

Actually python's ZipFile doesn't do that either.
  • Loading branch information
deathaxe committed Oct 9, 2023
1 parent aade3e8 commit 86831be
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion package_control/package_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,10 @@ def _extract_zip(self, name, zf, src_dir, dest_dir, extracted_files=None):
with zf.open(info) as fsrc, open(dest, 'wb') as fdst:
shutil.copyfileobj(fsrc, fdst)

except IOError as e:
# restore file mode
os.chmod(dest, info.external_attr >> 16)

except OSError as e:
if e.errno == 5 or e.errno == 13: # permission denied
return True

Expand Down

0 comments on commit 86831be

Please sign in to comment.