diff options
author | 2015-10-06 17:20:01 +0000 | |
---|---|---|
committer | 2015-10-07 07:10:12 +0000 | |
commit | eab38e8b28474046a1b036b73a32aebf224de3bb (patch) | |
tree | a8a6094a4f732792a74f14e4f0d6124ab8192f5e /src/main/java/com/google/devtools/build/lib/bazel | |
parent | ad1114fa3bda235d9badeb907a07273a665dc99d (diff) |
Fix new_http_archive's strip_prefix for zips
The removal of the prefix was incorrectly applied to the zip entry
instead of the destination.
Fixes https://github.com/bazelbuild/bazel/issues/221
Tested:
- Added a copy of the existing integration test with zip archive
- bash compile.sh all
--
Change-Id: I5d5f75f66a17eb6f146afafb1f347a781490e616
Reviewed-on: https://bazel-review.googlesource.com/#/c/2084/
MOS_MIGRATED_REVID=104774296
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/bazel')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/bazel/repository/ZipFunction.java | 20 |
1 files changed, 11 insertions, 9 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 c797f7f63d..9f938c34d8 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 @@ -73,8 +73,7 @@ public class ZipFunction implements SkyFunction { if (entryPath.skip()) { continue; } - entry.setName(entryPath.getPathFragment().getPathString()); - extractZipEntry(reader, entry, destinationDirectory); + extractZipEntry(reader, entry, destinationDirectory, entryPath.getPathFragment()); } } catch (IOException e) { throw new RepositoryFunctionException(new IOException( @@ -92,16 +91,19 @@ public class ZipFunction implements SkyFunction { return new DecompressorValue(destinationDirectory); } - private void extractZipEntry(ZipReader reader, ZipFileEntry entry, Path destinationDirectory) + private void extractZipEntry( + ZipReader reader, + ZipFileEntry entry, + Path destinationDirectory, + PathFragment strippedRelativePath) throws IOException { - String relativeString = entry.getName(); - PathFragment relativePath = new PathFragment(relativeString); - if (relativePath.isAbsolute()) { + if (strippedRelativePath.isAbsolute()) { throw new IOException( - String.format("Failed to extract %s, zipped paths cannot be absolute", relativePath)); + String.format( + "Failed to extract %s, zipped paths cannot be absolute", strippedRelativePath)); } - Path outputPath = destinationDirectory.getRelative(relativePath); - int permissions = getPermissions(entry.getExternalAttributes(), relativeString); + Path outputPath = destinationDirectory.getRelative(strippedRelativePath); + int permissions = getPermissions(entry.getExternalAttributes(), entry.getName()); FileSystemUtils.createDirectoryAndParents(outputPath.getParentDirectory()); boolean isDirectory = (permissions & 040000) == 040000; if (isDirectory) { |