summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraiuto <aiuto@google.com>2024-01-09 22:07:09 -0500
committerGitHub <noreply@github.com>2024-01-09 22:07:09 -0500
commit42c88c8ef83b0b16e365022dedf94612c6d13b61 (patch)
tree989247ac4f2e94bcfc673a36b553e659da4eb32b
parentc3a1ffb8c4e9887a3728083531f3463b512f2bec (diff)
downloadbazelbuild-rules_pkg-42c88c8ef83b0b16e365022dedf94612c6d13b61.tar.gz
Explicitly set the FILE bit in zip external attributes. (#804)
* 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
-rw-r--r--pkg/private/zip/build_zip.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/pkg/private/zip/build_zip.py b/pkg/private/zip/build_zip.py
index ca48a08..5a191b7 100644
--- a/pkg/private/zip/build_zip.py
+++ b/pkg/private/zip/build_zip.py
@@ -26,9 +26,10 @@ from pkg.private import manifest
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."""
@@ -168,6 +169,7 @@ class ZipWriter(object):
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: