Logical rollforward of https://github.com/bazelbuild/bazel/commit/e2e235359ccdc4b6a122586b9d7c99abbddd65f5. That commit was reverted because it tickled an unrelated bug accidentally exercised by a Google-internal test. The unrelated bug has been fixed separately. RELNOTES: None PiperOrigin-RevId: 234620238
diff --git a/src/main/java/com/google/devtools/build/lib/actions/FileValue.java b/src/main/java/com/google/devtools/build/lib/actions/FileValue.java index f03268a..7c2f416 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/FileValue.java +++ b/src/main/java/com/google/devtools/build/lib/actions/FileValue.java
@@ -166,16 +166,16 @@ public static FileValue value( ImmutableList<RootedPath> logicalChainDuringResolution, RootedPath originalRootedPath, - FileStateValue fileStateValue, + FileStateValue fileStateValueFromAncestors, RootedPath realRootedPath, FileStateValue realFileStateValue) { if (originalRootedPath.equals(realRootedPath)) { Preconditions.checkState( - fileStateValue.getType() != FileStateType.SYMLINK, - "originalRootedPath: %s, fileStateValue: %s, realRootedPath: %s, " - + "fileStateValueFromAncestors: %s", + fileStateValueFromAncestors.getType() != FileStateType.SYMLINK, + "originalRootedPath: %s, fileStateValueFromAncestors: %s, " + + "realRootedPath: %s, fileStateValueFromAncestors: %s", originalRootedPath, - fileStateValue, + fileStateValueFromAncestors, realRootedPath, realFileStateValue); Preconditions.checkState( @@ -185,7 +185,7 @@ "logicalChainDuringResolution: %s, originalRootedPath: %s", logicalChainDuringResolution, originalRootedPath); - return new RegularFileValue(originalRootedPath, fileStateValue); + return new RegularFileValue(originalRootedPath, fileStateValueFromAncestors); } boolean shouldStoreChain; @@ -200,11 +200,11 @@ shouldStoreChain = true; break; default: - throw new IllegalStateException(fileStateValue.getType().toString()); + throw new IllegalStateException(realFileStateValue.getType().toString()); } - if (fileStateValue.getType() == FileStateType.SYMLINK) { - PathFragment symlinkTarget = fileStateValue.getSymlinkTarget(); + if (fileStateValueFromAncestors.getType() == FileStateType.SYMLINK) { + PathFragment symlinkTarget = fileStateValueFromAncestors.getSymlinkTarget(); return shouldStoreChain ? new SymlinkFileValueWithStoredChain( realRootedPath, realFileStateValue, logicalChainDuringResolution, symlinkTarget)
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 0f0aaa6..6f02026 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
@@ -117,17 +117,6 @@ RootedPath realRootedPath = rootedPathFromAncestors; FileStateValue realFileStateValue = fileStateValueFromAncestors; - FileStateValue fileStateValue; - if (rootedPath.equals(realRootedPath)) { - fileStateValue = Preconditions.checkNotNull(realFileStateValue, rootedPath); - } else { - // TODO(b/123922036): Yep, this is useless & wasted work. - fileStateValue = (FileStateValue) env.getValue(FileStateValue.key(rootedPath)); - if (fileStateValue == null) { - return null; - } - } - while (realFileStateValue.getType().isSymlink()) { PartialResolutionResult getSymlinkTargetRootedPathResult = getSymlinkTargetRootedPath( @@ -147,7 +136,7 @@ ImmutableList.copyOf(logicalChain), rootedPath, // TODO(b/123922036): This is a bug. Should be 'fileStateValueFromAncestors'. - fileStateValue, + fileStateValueFromAncestors, realRootedPath, realFileStateValue); }