aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main
diff options
context:
space:
mode:
authorGravatar Nathan Harmata <nharmata@google.com>2016-10-17 15:49:34 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2016-10-18 10:55:58 +0000
commitc0f3d4ee3aa81747f879efec4cbb65d4e72605d8 (patch)
treefc8af0f82f35ac0fea587ce6b263430a480e5918 /src/main
parente0d7a540e3c615c628f63fcaaaba0c47fca2cb25 (diff)
Don't bother getting the not-real FileStateValue for a path whose parent doesn't exist.
In addition to saving a filesystem operation, this removes a source of a potential filesystem inconsistency. -- MOS_MIGRATED_REVID=136355008
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/FileFunction.java45
1 files changed, 24 insertions, 21 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..617baad74e 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
@@ -18,6 +18,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import com.google.devtools.build.lib.pkgcache.PathPackageLocator;
+import com.google.devtools.build.lib.skyframe.FileStateValue.Type;
import com.google.devtools.build.lib.util.Pair;
import com.google.devtools.build.lib.util.Preconditions;
import com.google.devtools.build.lib.vfs.Path;
@@ -80,34 +81,36 @@ public class FileFunction implements SkyFunction {
}
realRootedPath = resolvedState.getFirst();
realFileStateValue = resolvedState.getSecond();
+ if (realFileStateValue.getType() == Type.NONEXISTENT) {
+ return FileValue.value(
+ rootedPath,
+ FileStateValue.NONEXISTENT_FILE_STATE_NODE,
+ realRootedPath,
+ realFileStateValue);
+ }
}
- 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;
+ if (rootedPath.equals(realRootedPath)) {
+ fileStateValue = Preconditions.checkNotNull(realFileStateValue, rootedPath);
+ } else {
+ try {
+ fileStateValue =
+ (FileStateValue)
+ env.getValueOrThrow(
+ FileStateValue.key(rootedPath), FileOutsidePackageRootsException.class);
+ } catch (FileOutsidePackageRootsException e) {
+ throw new FileFunctionException(
+ new FileOutsidePackageRootsException(rootedPath), Transience.PERSISTENT);
+ }
+ if (fileStateValue == null) {
+ return null;
+ }
}
- if (fileStateValue == null) {
- return null;
- }
if (realFileStateValue == null) {
realRootedPath = rootedPath;
realFileStateValue = fileStateValue;
- } else if (rootedPath.equals(realRootedPath) && !fileStateValue.equals(realFileStateValue)) {
- String message = String.format(
- "Some filesystem operations implied %s was a %s but others made us think it was a %s",
- rootedPath.asPath().getPathString(),
- fileStateValue.prettyPrint(),
- realFileStateValue.prettyPrint());
- throw new FileFunctionException(new InconsistentFilesystemException(message),
- Transience.TRANSIENT);
}
ArrayList<RootedPath> symlinkChain = new ArrayList<>();