diff options
author | Kristina Chodorow <kchodorow@google.com> | 2015-10-20 16:01:32 +0000 |
---|---|---|
committer | Philipp Wollermann <philwo@google.com> | 2015-10-20 16:39:07 +0000 |
commit | a58db9b6ecdfdb32abd3a7e90c290d6269cfb543 (patch) | |
tree | 6e8b7597c2753dc1eecb9e725dd9f6116ab1ab1e /src/main/java | |
parent | 93ed7f114ee9be35f41eff5476963745baae4c12 (diff) |
Add support for Windows zip permissions
Fixes #518.
RELNOTES: Add support for Windows-created zip files with non-posix permissions.
--
MOS_MIGRATED_REVID=105865785
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/bazel/repository/ZipFunction.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/ZipFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/ZipFunction.java index 158026acbd..5951a37d48 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/ZipFunction.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/ZipFunction.java @@ -42,6 +42,9 @@ public class ZipFunction implements SkyFunction { public static final SkyFunctionName NAME = SkyFunctionName.create("ZIP_FUNCTION"); + private static final int WINDOWS_DIRECTORY = 0x10; + private static final int WINDOWS_FILE = 0x20; + /** * This unzips the zip file to a sibling directory of {@link DecompressorDescriptor#archivePath}. * The zip file is expected to have the WORKSPACE file at the top level, e.g.: @@ -137,10 +140,11 @@ public class ZipFunction implements SkyFunction { // checks if the filename ends with / (for directories) and extra attributes set to 0 for // files. From https://github.com/miloyip/rapidjson/archive/v1.0.2.zip, it looks like // executables end up with "normal" (posix) permissions (oddly), so they'll be handled above. - if (path.endsWith("/")) { + int windowsPermission = permissions & 0xff; + if (path.endsWith("/") || (windowsPermission & WINDOWS_DIRECTORY) == WINDOWS_DIRECTORY) { // Directory. return 040755; - } else if (permissions == 0) { + } else if (permissions == 0 || (windowsPermission & WINDOWS_FILE) == WINDOWS_FILE) { // File. return 010644; } |