Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
buchgr committed Mar 6, 2019
1 parent 995751e commit a38b6c2
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import com.google.common.base.Function;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
Expand Down Expand Up @@ -68,20 +69,28 @@ public PathFragment apply(Artifact artifact) {
/**
* Returns a TreeArtifactValue out of the given Artifact-relative path fragments
* and their corresponding FileArtifactValues.
*
* <p>All {@code childFileValues} must return the same value for
* {@link FileArtifactValue#isRemote()}.
*/
static TreeArtifactValue create(Map<TreeFileArtifact, FileArtifactValue> childFileValues) {
Map<String, FileArtifactValue> digestBuilder =
Maps.newHashMapWithExpectedSize(childFileValues.size());
boolean isRemote = true;
Boolean isRemote = null;
for (Map.Entry<TreeFileArtifact, FileArtifactValue> e : childFileValues.entrySet()) {
isRemote = isRemote && e.getValue().isRemote();
digestBuilder.put(e.getKey().getParentRelativePath().getPathString(), e.getValue());
FileArtifactValue v = e.getValue();
if (isRemote == null) {
isRemote = v.isRemote();
}
Preconditions.checkArgument(v.isRemote() == isRemote, "files in a tree artifact must either"
+ " be all remote or all local.");
digestBuilder.put(e.getKey().getParentRelativePath().getPathString(), v);
}

return new TreeArtifactValue(
DigestUtils.fromMetadata(digestBuilder).getDigestBytesUnsafe(),
ImmutableMap.copyOf(childFileValues),
isRemote);
isRemote != null ? isRemote : false);
}

FileArtifactValue getSelfData() {
Expand Down Expand Up @@ -110,7 +119,7 @@ Map<TreeFileArtifact, FileArtifactValue> getChildValues() {
}

/**
* Returns {@code true} if at least one {@link TreeFileArtifact} is only stored remotely.
* Returns {@code true} if the @link TreeFileArtifact}s are only stored remotely.
*/
public boolean isRemote() {
return isRemote;
Expand Down

0 comments on commit a38b6c2

Please sign in to comment.