aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/skyframe/FileFunction.java
diff options
context:
space:
mode:
authorGravatar Nathan Harmata <nharmata@google.com>2016-10-13 18:17:48 +0000
committerGravatar Yue Gan <yueg@google.com>2016-10-14 09:32:53 +0000
commit0c7a42a09d85ddffd9b860bcb31e4c43a00632c1 (patch)
treeec637fb0aedd23c75b066bbbc27f96ae0362324c /src/main/java/com/google/devtools/build/lib/skyframe/FileFunction.java
parent7c3d668a9c598110256495d2863b53c9d40befb1 (diff)
Slight refactor of ExternalFilesHelper:
-Make FileType and ExternalFileAction public. -Have producers use ExternalFileAction, rather than a boolean, to specify the desired behavior. And a big change in semantics (doesn't affect Bazel): -Replace ExternalFileAction.ERROR_OUT with ExternalFileAction.ASSUME_NON_EXISTENT_AND_IMMUTABLE, which does what it sounds like. This new action, like the old ERROR_OUT, is _not_ used in Bazel. -- MOS_MIGRATED_REVID=136063159
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/FileFunction.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/FileFunction.java50
1 files changed, 6 insertions, 44 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/FileFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/FileFunction.java
index 8404f53aa7..86bb9e6aab 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/FileFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/FileFunction.java
@@ -62,19 +62,7 @@ public class FileFunction implements SkyFunction {
// symlink cycle, we want to detect that quickly as it gives a more informative error message
// than we'd get doing bogus filesystem operations.
if (!relativePath.equals(PathFragment.EMPTY_FRAGMENT)) {
- Pair<RootedPath, FileStateValue> resolvedState = null;
-
- try {
- resolvedState = resolveFromAncestors(rootedPath, env);
- } catch (FileOutsidePackageRootsException e) {
- // When getting a FileOutsidePackageRootsException caused by an external file symlink
- // somewhere in this file's path, rethrow an exception with this file's path, so the error
- // message mentions this file instead of the first ancestor path where the external file
- // error is observed
- throw new FileFunctionException(
- new FileOutsidePackageRootsException(rootedPath), Transience.PERSISTENT);
- }
-
+ Pair<RootedPath, FileStateValue> resolvedState = resolveFromAncestors(rootedPath, env);
if (resolvedState == null) {
return null;
}
@@ -82,18 +70,7 @@ public class FileFunction implements SkyFunction {
realFileStateValue = resolvedState.getSecond();
}
- FileStateValue fileStateValue = null;
-
- try {
- fileStateValue =
- (FileStateValue)
- env.getValueOrThrow(
- FileStateValue.key(rootedPath), FileOutsidePackageRootsException.class);
- } catch (FileOutsidePackageRootsException e) {
- throw new FileFunctionException(
- new FileOutsidePackageRootsException(rootedPath), Transience.PERSISTENT);
- }
-
+ FileStateValue fileStateValue = (FileStateValue) env.getValue(FileStateValue.key(rootedPath));
if (fileStateValue == null) {
return null;
}
@@ -133,7 +110,7 @@ public class FileFunction implements SkyFunction {
@Nullable
private static Pair<RootedPath, FileStateValue> resolveFromAncestors(
RootedPath rootedPath, Environment env)
- throws FileFunctionException, FileOutsidePackageRootsException, InterruptedException {
+ throws FileFunctionException, InterruptedException {
PathFragment relativePath = rootedPath.getRelativePath();
RootedPath realRootedPath = rootedPath;
FileValue parentFileValue = null;
@@ -141,11 +118,7 @@ public class FileFunction implements SkyFunction {
RootedPath parentRootedPath = RootedPath.toRootedPath(rootedPath.getRoot(),
relativePath.getParentDirectory());
- parentFileValue =
- (FileValue)
- env.getValueOrThrow(
- FileValue.key(parentRootedPath), FileOutsidePackageRootsException.class);
-
+ parentFileValue = (FileValue) env.getValue(FileValue.key(parentRootedPath));
if (parentFileValue == null) {
return null;
}
@@ -161,8 +134,7 @@ public class FileFunction implements SkyFunction {
}
FileStateValue realFileStateValue =
(FileStateValue)
- env.getValueOrThrow(
- FileStateValue.key(realRootedPath), FileOutsidePackageRootsException.class);
+ env.getValue(FileStateValue.key(realRootedPath));
if (realFileStateValue == null) {
return null;
@@ -278,17 +250,7 @@ public class FileFunction implements SkyFunction {
throw new FileFunctionException(Preconditions.checkNotNull(fse, rootedPath));
}
- try {
- return resolveFromAncestors(symlinkTargetRootedPath, env);
- } catch (FileOutsidePackageRootsException e) {
- // At this point we know this file node is a symlink leading to an external file. Mark the
- // exception to be a specific SymlinkOutsidePackageRootsException. The error will be bubbled
- // up further but no path information will be updated again. This allows preserving the
- // information about the symlink crossing the internal/external boundary.
- throw new FileFunctionException(
- new SymlinkOutsidePackageRootsException(rootedPath, symlinkTargetRootedPath),
- Transience.PERSISTENT);
- }
+ return resolveFromAncestors(symlinkTargetRootedPath, env);
}
private static final Predicate<RootedPath> isPathPredicate(final Path path) {