diff options
author | 2016-09-19 20:59:36 +0000 | |
---|---|---|
committer | 2016-09-20 06:46:17 +0000 | |
commit | 4e2f75d8e60020f13a7df452488ec4cc7a719f03 (patch) | |
tree | fb97f63a4047a034699002a30450cb2a074256cc /src/main/java/com/google/devtools/build | |
parent | 243cd7559926dd5ef03609197b5c6bfaf874eaaa (diff) |
Fixed symbolic link and hard link path not stripped when "strip_prefix" is set.
--
MOS_MIGRATED_REVID=133628392
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/bazel/repository/CompressedTarFunction.java | 5 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/vfs/FileSystemUtils.java | 16 |
2 files changed, 12 insertions, 9 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/CompressedTarFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/CompressedTarFunction.java index daf6e66267..8b4a5f4022 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/CompressedTarFunction.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/CompressedTarFunction.java @@ -58,7 +58,10 @@ public abstract class CompressedTarFunction implements Decompressor { FileSystemUtils.createDirectoryAndParents(filename); } else { if (entry.isSymbolicLink() || entry.isLink()) { - PathFragment linkName = new PathFragment(entry.getLinkName()); + // Strip the prefix from the link path if set + StripPrefixedPath linkPath = + StripPrefixedPath.maybeDeprefix(entry.getLinkName(), prefix); + PathFragment linkName = linkPath.getPathFragment(); if (linkName.isAbsolute()) { linkName = linkName.relativeTo(PathFragment.ROOT_DIR); linkName = descriptor.repositoryPath().getRelative(linkName).asFragment(); diff --git a/src/main/java/com/google/devtools/build/lib/vfs/FileSystemUtils.java b/src/main/java/com/google/devtools/build/lib/vfs/FileSystemUtils.java index c8d1f3c2c4..73a9a5119f 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/FileSystemUtils.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/FileSystemUtils.java @@ -1010,19 +1010,19 @@ public class FileSystemUtils { */ public static void createHardLink(Path linkPath, Path originalPath) throws IOException { - // Regular file - if (originalPath.isFile()) { + // Directory + if (originalPath.isDirectory()) { + for (Path originalSubpath : originalPath.getDirectoryEntries()) { + Path linkSubpath = linkPath.getRelative(originalSubpath.relativeTo(originalPath)); + createHardLink(linkSubpath, originalSubpath); + } + // Other types of file + } else { Path parentDir = linkPath.getParentDirectory(); if (!parentDir.exists()) { FileSystemUtils.createDirectoryAndParents(parentDir); } originalPath.createHardLink(linkPath); - // Directory - } else if (originalPath.isDirectory()) { - for (Path originalSubpath : originalPath.getDirectoryEntries()) { - Path linkSubpath = linkPath.getRelative(originalSubpath.relativeTo(originalPath)); - createHardLink(linkSubpath, originalSubpath); - } } } } |