diff options
author | felly <felly@google.com> | 2018-06-12 07:40:49 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-06-12 07:42:01 -0700 |
commit | 45e28e50172583ef2a62804979cb515b85c46462 (patch) | |
tree | 7502f88969ac1e6ad25b9a9a4ada84a31a9a5904 /src/main/java/com/google/devtools/build | |
parent | 21d60de9af1770b6ef08702d5dc9e23ed928df10 (diff) |
Support delete() in ActionFS.
RELNOTES: None
PiperOrigin-RevId: 200213204
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java index 726042588b..af2fe79920 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java @@ -177,11 +177,9 @@ final class ActionFileSystem extends AbstractFileSystemWithCustomStat @Override public void onInsert(ActionInput dest, byte[] digest, long size, int backendIndex) throws IOException { - OutputMetadata output = outputs.getUnchecked(dest.getExecPath()); - if (output != null) { - output.set(new RemoteFileArtifactValue(digest, size, backendIndex), - /*notifyConsumer=*/ false); - } + outputs.getUnchecked(dest.getExecPath()).set( + new RemoteFileArtifactValue(digest, size, backendIndex), + /*notifyConsumer=*/ false); } // -------------------- FileSystem implementation -------------------- @@ -271,8 +269,9 @@ final class ActionFileSystem extends AbstractFileSystemWithCustomStat @Override public boolean delete(Path path) throws IOException { - // TODO(felly): Support file deletion. - return false; + PathFragment execPath = asExecPath(path); + OutputMetadata output = outputs.getIfPresent(execPath); + return output != null && outputs.asMap().remove(execPath, output); } @Override @@ -367,12 +366,9 @@ final class ActionFileSystem extends AbstractFileSystemWithCustomStat createSymbolicLinkErrorMessage( linkPath, targetFragment, targetFragment + " is not an input.")); } - OutputMetadata outputHolder = outputs.getUnchecked(asExecPath(linkPath)); - if (outputHolder == null) { - throw new FileNotFoundException( - createSymbolicLinkErrorMessage( - linkPath, targetFragment, linkPath + " is not an output.")); - } + OutputMetadata outputHolder = Preconditions.checkNotNull( + outputs.getUnchecked(asExecPath(linkPath)), + "Unexpected null output path: %s", linkPath); if (sourceRootIndex >= 0) { Preconditions.checkState(!targetExecPath.startsWith(outputPathFragment), "Target exec path " + "%s does not start with output path fragment %s", targetExecPath, outputPathFragment); @@ -431,10 +427,9 @@ final class ActionFileSystem extends AbstractFileSystemWithCustomStat if (metadata instanceof SourceFileArtifactValue) { return resolveSourcePath((SourceFileArtifactValue) metadata).getInputStream(); } - Preconditions.checkArgument( - !(metadata instanceof RemoteFileArtifactValue), - "getInputStream called for remote file: %s", - path); + if (metadata instanceof RemoteFileArtifactValue) { + throw new IOException("ActionFileSystem cannot read remote file: " + path); + } return getSourcePath(path.asFragment()).getInputStream(); } |