@@ -86,6 +86,7 @@ public class BazelOutputService implements OutputService {
8686 private final boolean verboseFailures ;
8787 private final RemoteRetrier retrier ;
8888 private final ReferenceCountedChannel channel ;
89+ @ Nullable private final String lastBuildId ;
8990
9091 @ Nullable private String buildId ;
9192 @ Nullable private PathFragment outputPathTarget ;
@@ -100,7 +101,8 @@ public BazelOutputService(
100101 String remoteOutputServiceOutputPathPrefix ,
101102 boolean verboseFailures ,
102103 RemoteRetrier retrier ,
103- ReferenceCountedChannel channel ) {
104+ ReferenceCountedChannel channel ,
105+ @ Nullable String lastBuildId ) {
104106 this .outputBaseId = DigestUtil .hashCodeToString (md5 ().hashString (outputBase .toString (), UTF_8 ));
105107 this .execRootSupplier = execRootSupplier ;
106108 this .outputPathSupplier = outputPathSupplier ;
@@ -111,6 +113,7 @@ public BazelOutputService(
111113 this .verboseFailures = verboseFailures ;
112114 this .retrier = retrier ;
113115 this .channel = channel ;
116+ this .lastBuildId = lastBuildId ;
114117 }
115118
116119 public void shutdown () {
@@ -244,7 +247,12 @@ public ModifiedFileSet startBuild(
244247 outputPathTarget = constructOutputPathTarget (outputPathPrefix , response );
245248 prepareOutputPath (outputPath , outputPathTarget );
246249
247- if (finalizeActions ) {
250+ if (finalizeActions && response .hasInitialOutputPathContents ()) {
251+ var initialOutputPathContents = response .getInitialOutputPathContents ();
252+ if (!initialOutputPathContents .getBuildId ().equals (lastBuildId )) {
253+ return ModifiedFileSet .EVERYTHING_DELETED ;
254+ }
255+
248256 // TODO(chiwang): Handle StartBuildResponse.initial_output_path_contents
249257 }
250258
0 commit comments