in src/main/java/com/google/devtools/build/remote/client/AbstractRemoteActionCache.java [178:202]
protected void downloadFile(
Path path, Digest digest, boolean isExecutable, @Nullable ByteString content)
throws IOException {
Files.createDirectories(path.getParent());
if (digest.getSizeBytes() == 0) {
// Handle empty file locally.
Files.createFile(path);
} else {
if (content != null && !content.isEmpty()) {
try (OutputStream stream = Files.newOutputStream(path)) {
content.writeTo(stream);
}
} else {
downloadBlob(digest, path);
Digest receivedDigest = digestUtil.compute(path);
if (!receivedDigest.equals(digest)) {
throw new IOException("Digest does not match " + receivedDigest + " != " + digest);
}
}
}
// setExecutable doesn't work on Windows, nor is it required.
if (!System.getProperty("os.name").startsWith("Windows")) {
setExecutable(path, isExecutable);
}
}