Skip to content

Commit

Permalink
Explicitly set the FILE bit in zip external attributes. (#804)
Browse files Browse the repository at this point in the history
* Explicitly set the FILE bit in zip external attributes.

This should not be needed, but it seems to be for some Azure users.

Fixes #802

* remove a comment that proved unneeded
  • Loading branch information
aiuto authored Jan 10, 2024
1 parent c3a1ffb commit 42c88c8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/private/zip/build_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
ZIP_EPOCH = 315532800

# Unix dir bit and Windows dir bit. Magic from zip spec
UNIX_DIR_BIT = 0o40000
MSDOS_DIR_BIT = 0x10
UNIX_FILE_BIT = 0o100000
UNIX_SYMLINK_BIT = 0o120000
UNIX_DIR_BIT = 0o040000
MSDOS_DIR_BIT = 0x10

def _create_argument_parser():
"""Creates the command line arg parser."""
Expand Down Expand Up @@ -168,6 +169,7 @@ def add_manifest_entry(self, entry):
if entry_type == manifest.ENTRY_IS_FILE:
entry_info.compress_type = self.compression_type
# Using utf-8 for the file names is for python <3.7 compatibility.
entry_info.external_attr |= UNIX_FILE_BIT << 16
with open(src.encode('utf-8'), 'rb') as src_content:
self.writestr(entry_info, src_content.read(), compresslevel=self.compression_level)
elif entry_type == manifest.ENTRY_IS_DIR:
Expand Down

0 comments on commit 42c88c8

Please sign in to comment.