Skip to content

Commit

Permalink
remote: fix unexpected IO error (not a directory)
Browse files Browse the repository at this point in the history
  • Loading branch information
buchgr committed Jan 18, 2019
1 parent ce91f76 commit fc44891
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.devtools.build.lib.actions.Artifact.ArtifactExpander;
import com.google.devtools.build.lib.actions.Artifact.SpecialArtifact;
import com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -218,4 +219,16 @@ public static List<ActionInput> expandArtifacts(Iterable<? extends ActionInput>
public static Iterable<String> toExecPaths(Iterable<? extends ActionInput> artifacts) {
return Iterables.transform(artifacts, EXEC_PATH_STRING_FORMATTER);
}

/**
* Returns the {@link Path} for an {@link ActionInput}.
*/
public static Path toPath(ActionInput input, Path execRoot) {
Preconditions.checkNotNull(input, "input");
Preconditions.checkNotNull(execRoot, "execRoot");

return (input instanceof Artifact)
? ((Artifact) input).getPath()
: execRoot.getRelative(input.getExecPath());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.devtools.build.lib.actions.ActionInput;
import com.google.devtools.build.lib.actions.ActionInputHelper;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.DigestOfDirectoryException;
import com.google.devtools.build.lib.actions.FileArtifactValue;
Expand Down Expand Up @@ -60,10 +61,7 @@ public FileArtifactValue getMetadata(ActionInput input) throws IOException {
.get(
input.getExecPathString(),
() -> {
Path path =
(input instanceof Artifact)
? ((Artifact) input).getPath()
: execRoot.getRelative(input.getExecPath());
Path path = ActionInputHelper.toPath(input, execRoot);
try {
FileArtifactValue metadata = FileArtifactValue.create(path);
if (metadata.getType().isDirectory()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ private TreeNode buildParentNode(
Preconditions.checkArgument(
inputsStart == inputsEnd - 1, "Encountered two inputs with the same path.");
ActionInput input = inputs.get(inputsStart);
Path leafPath = execRoot.getRelative(input.getExecPathString());
Path leafPath = ActionInputHelper.toPath(input, execRoot);
if (!(input instanceof VirtualActionInput) && uploadSymlinks) {
FileStatus stat = leafPath.stat(Symlinks.NOFOLLOW);
if (stat.isSymbolicLink()) {
Expand Down Expand Up @@ -405,7 +405,7 @@ private synchronized Directory getOrComputeDirectory(TreeNode node) throws IOExc
if (uploadSymlinks) {
// We need to stat the input to check whether it is a symlink.
// getInputMetadata only gives target metadata.
Path inputPath = execRoot.getRelative(input.getExecPath());
Path inputPath = ActionInputHelper.toPath(input, execRoot);
FileStatus stat = inputPath.stat(Symlinks.NOFOLLOW);
if (stat.isSymbolicLink()) {
PathFragment target = inputPath.readSymbolicLink();
Expand Down

0 comments on commit fc44891

Please sign in to comment.