aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/vfs/UnionFileSystem.java
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-09-07 14:33:29 +0000
committerGravatar Yun Peng <pcloudy@google.com>2016-09-08 08:43:41 +0000
commite1cd9509862aef684b4dbbdfd15d0b877fb8fad3 (patch)
treeabc9f51fa1ecdb86854b0c39ae56dd6844cc0eb6 /src/main/java/com/google/devtools/build/lib/vfs/UnionFileSystem.java
parent0d3e8ae7c2bd6937bc0ffd32963d6635bfe825f5 (diff)
Fixed the issue that hard links are handled improperly when bazel decompresses tarballs.
Issue link: https://github.com/bazelbuild/bazel/issues/574 -- MOS_MIGRATED_REVID=132434278
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/vfs/UnionFileSystem.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/vfs/UnionFileSystem.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/UnionFileSystem.java b/src/main/java/com/google/devtools/build/lib/vfs/UnionFileSystem.java
index cf67d1e749..a0a09555f2 100644
--- a/src/main/java/com/google/devtools/build/lib/vfs/UnionFileSystem.java
+++ b/src/main/java/com/google/devtools/build/lib/vfs/UnionFileSystem.java
@@ -173,6 +173,11 @@ public class UnionFileSystem extends FileSystem {
}
@Override
+ public boolean supportsHardLinksNatively() {
+ return true;
+ }
+
+ @Override
public boolean isFilePathCaseSensitive() {
return this.isCaseSensitive;
}
@@ -435,4 +440,20 @@ public class UnionFileSystem extends FileSystem {
sourceDelegate.delete(sourcePath);
}
}
+
+ @Override
+ protected void createFSDependentHardLink(Path linkPath, Path originalPath)
+ throws IOException {
+ checkModifiable();
+
+ FileSystem originalDelegate = getDelegate(originalPath);
+ FileSystem linkDelegate = getDelegate(linkPath);
+
+ if (!originalDelegate.equals(linkDelegate) || !linkDelegate.supportsHardLinksNatively()) {
+ throw new UnsupportedOperationException(
+ "Attempted to create a hard link, but hard link support is disabled.");
+ }
+ linkDelegate.createFSDependentHardLink(
+ adjustPath(linkPath, linkDelegate), adjustPath(originalPath, originalDelegate));
+ }
}