diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteActionFileSystem.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteActionFileSystem.java index a24ffac2a14b95..d7e130d8709bbc 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteActionFileSystem.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteActionFileSystem.java @@ -605,14 +605,16 @@ private FileStatus statUnchecked( } } - try { - return remoteOutputTree.stat(path, /* followSymlinks= */ false); - } catch (FileNotFoundException e) { - if (statSources == StatSources.ALL) { - return localFs.getPath(path).stat(Symlinks.NOFOLLOW); - } - throw e; + FileStatus stat = remoteOutputTree.statIfFound(path, /* followSymlinks= */ false); + if (stat != null) { + return stat; } + + if (statSources == StatSources.ALL) { + return localFs.getPath(path).stat(Symlinks.NOFOLLOW); + } + + throw new FileNotFoundException(path.getPathString() + " (No such file or directory)"); } private static FileStatusWithMetadata statFromMetadata(FileArtifactValue m) {