Skip to content

Commit

Permalink
Enforce that none of the inputs passed to prefetchFiles are directories.
Browse files Browse the repository at this point in the history
This precondition should hold today (otherwise we'd later attempt to prefetch the directory as it if were a file and fail), but this change makes the ensuing crash a little more obvious.

PiperOrigin-RevId: 498997318
Change-Id: I7f8df36c56b969c939f42e2d937a21be39520f23
  • Loading branch information
tjgq authored and copybara-github committed Jan 2, 2023
1 parent ca8103a commit 763f966
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.
package com.google.devtools.build.lib.remote;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static com.google.devtools.build.lib.remote.util.RxFutures.toCompletable;
Expand Down Expand Up @@ -158,6 +159,8 @@ protected Completable onErrorResumeNext(Throwable error) {
* Fetches remotely stored action outputs, that are inputs to this spawn, and stores them under
* their path in the output base.
*
* <p>The {@code inputs} may not contain any unexpanded directories.
*
* <p>This method is safe to be called concurrently from spawn runners before running any local
* spawn.
*
Expand All @@ -176,6 +179,9 @@ protected ListenableFuture<Void> prefetchFiles(
Map<SpecialArtifact, List<TreeFileArtifact>> trees = new HashMap<>();
List<ActionInput> files = new ArrayList<>();
for (ActionInput input : inputs) {
checkArgument(!input.isDirectory(), "cannot prefetch a directory");

// Source artifacts don't need to be fetched.
if (input instanceof Artifact && ((Artifact) input).isSourceArtifact()) {
continue;
}
Expand Down

0 comments on commit 763f966

Please sign in to comment.