aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar Xin Gao <xingao@google.com>2016-09-19 20:59:36 +0000
committerGravatar Laszlo Csomor <laszlocsomor@google.com>2016-09-20 06:46:17 +0000
commit4e2f75d8e60020f13a7df452488ec4cc7a719f03 (patch)
treefb97f63a4047a034699002a30450cb2a074256cc /src/main/java/com/google/devtools/build
parent243cd7559926dd5ef03609197b5c6bfaf874eaaa (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.java5
-rw-r--r--src/main/java/com/google/devtools/build/lib/vfs/FileSystemUtils.java16
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);
- }
}
}
}