From cb1af4ee0915fc294f61a97dc9ef84c4f246dd78 Mon Sep 17 00:00:00 2001 From: felly Date: Tue, 12 Jun 2018 16:51:35 -0700 Subject: Fix a bug with flush() not flushing on local writes in ActionFS, and add unit test coverage for this. Note that ActionFS is not generic enough to make use of FileSystemTest. RELNOTES: None PiperOrigin-RevId: 200304871 --- .../build/lib/skyframe/ActionExecutionFunction.java | 2 +- .../devtools/build/lib/skyframe/ActionFileSystem.java | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src/main/java/com/google/devtools/build') diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java index 46d81b475c..612632e0f6 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java @@ -216,7 +216,7 @@ public class ActionExecutionFunction implements SkyFunction, CompletionReceiver state.actionFileSystem = new ActionFileSystem( skyframeActionExecutor.getExecutorFileSystem(), - skyframeActionExecutor.getExecRoot(), + skyframeActionExecutor.getExecRoot().asFragment(), directories.getRelativeOutputPath(), skyframeActionExecutor.getSourceRoots(), checkedInputs.first, 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 af2fe79920..bb4904283c 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 @@ -97,7 +97,7 @@ final class ActionFileSystem extends AbstractFileSystemWithCustomStat ActionFileSystem( FileSystem delegate, - Path execRoot, + PathFragment execRoot, String relativeOutputPath, ImmutableList sourceRoots, ActionInputMap inputArtifactData, @@ -107,7 +107,7 @@ final class ActionFileSystem extends AbstractFileSystemWithCustomStat Profiler.instance().profile(ProfilerTask.ACTION_FS_STAGING, "staging")) { this.delegate = delegate; - this.execRootFragment = execRoot.asFragment(); + this.execRootFragment = execRoot; this.outputPathFragment = execRootFragment.getRelative(relativeOutputPath); this.sourceRoots = sourceRoots @@ -639,10 +639,15 @@ final class ActionFileSystem extends AbstractFileSystemWithCustomStat return new ByteArrayOutputStream() { @Override public void close() throws IOException { + flush(); super.close(); + } + + @Override + public void flush() throws IOException { + super.flush(); byte[] data = toByteArray(); - set( - new InlineFileArtifactValue(data, Hashing.md5().hashBytes(data).asBytes()), + set(new InlineFileArtifactValue(data, Hashing.md5().hashBytes(data).asBytes()), /*notifyConsumer=*/ true); } }; -- cgit v1.2.3