From c0f3d4ee3aa81747f879efec4cbb65d4e72605d8 Mon Sep 17 00:00:00 2001 From: Nathan Harmata Date: Mon, 17 Oct 2016 15:49:34 +0000 Subject: 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 --- .../devtools/build/lib/skyframe/FileFunction.java | 45 ++++++++++++---------- 1 file changed, 24 insertions(+), 21 deletions(-) (limited to 'src/main') 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 symlinkChain = new ArrayList<>(); -- cgit v1.2.3