Skip to content

Commit

Permalink
IOException + merkleTree nullcheck + ignoring remoteDiscardMerkleTrees
Browse files Browse the repository at this point in the history
  • Loading branch information
bvatai-br committed Nov 26, 2024
1 parent 092e38f commit 3b6d138
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.SortedMap;
import javax.annotation.Nullable;
import java.io.FileWriter;
import java.io.IOException;

/**
* A value class representing an action which can be executed remotely.
Expand All @@ -43,6 +44,7 @@ public class RemoteAction {
private final RemoteActionExecutionContext remoteActionExecutionContext;
private final RemotePathResolver remotePathResolver;
@Nullable private final MerkleTree merkleTree;
@Nullable private final MerkleTree merkleTreeForDebug;
private final long inputBytes;
private final long inputFiles;
private final Digest commandHash;
Expand All @@ -66,6 +68,7 @@ public class RemoteAction {
this.remoteActionExecutionContext = remoteActionExecutionContext;
this.remotePathResolver = remotePathResolver;
this.merkleTree = remoteDiscardMerkleTrees ? null : merkleTree;
this.merkleTreeForDebug = merkleTree;
this.inputBytes = merkleTree.getInputBytes();
this.inputFiles = merkleTree.getInputFiles();
this.commandHash = commandHash;
Expand All @@ -76,10 +79,14 @@ public class RemoteAction {

private void writeDirectoryToFile(FileWriter writer, String root, MerkleTree t) throws IOException {
writer.write("[Root proto of " + root + "]\n");
writer.write(t.rootProto.toString());
for (String dirName : t.directories.keySet()) {
MerkleTree dir = t.directories.get(dirName);
writeDirectoryToFile(writer, root + "/" + dirName, dir);
if (t != null) {
writer.write(t.rootProto.toString());
for (String dirName : t.directories.keySet()) {
MerkleTree dir = t.directories.get(dirName);
writeDirectoryToFile(writer, root + "/" + dirName, dir);
}
} else {
writer.write("[merkleTree is null]\n");
}
}

Expand All @@ -95,7 +102,7 @@ public void writeToFile() {
writer.write("\n\n");

writer.write("[InputRoot]\n");
writeDirectoryToFile(writer, ".", merkleTree);
writeDirectoryToFile(writer, ".", merkleTreeForDebug);

System.out.println(jsonPath + " written.");
} catch (IOException e) {
Expand Down

0 comments on commit 3b6d138

Please sign in to comment.