diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteCacheClientFactory.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteCacheClientFactory.java index 8f68923f9fffcd..46070133aecfa9 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteCacheClientFactory.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteCacheClientFactory.java @@ -139,9 +139,6 @@ private static DiskCacheClient createDiskCache( throws IOException { Path cacheDir = workingDirectory.getRelative(Preconditions.checkNotNull(diskCachePath, "diskCachePath")); - if (!cacheDir.exists()) { - cacheDir.createDirectoryAndParents(); - } return new DiskCacheClient(cacheDir, verifyDownloads, checkActionResult, digestUtil); } @@ -153,12 +150,6 @@ private static RemoteCacheClient createDiskAndHttpCache( AuthAndTLSOptions authAndTlsOptions, DigestUtil digestUtil) throws IOException { - Path cacheDir = - workingDirectory.getRelative(Preconditions.checkNotNull(diskCachePath, "diskCachePath")); - if (!cacheDir.exists()) { - cacheDir.createDirectoryAndParents(); - } - RemoteCacheClient httpCache = createHttp(options, cred, authAndTlsOptions, digestUtil); return createDiskAndRemoteClient( workingDirectory, diff --git a/src/main/java/com/google/devtools/build/lib/remote/disk/DiskCacheClient.java b/src/main/java/com/google/devtools/build/lib/remote/disk/DiskCacheClient.java index 1c0777f77bc0de..806e59b4dcd36b 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/disk/DiskCacheClient.java +++ b/src/main/java/com/google/devtools/build/lib/remote/disk/DiskCacheClient.java @@ -59,7 +59,7 @@ public class DiskCacheClient implements RemoteCacheClient { * is {@code true} and blobs referenced by the AC are missing, ignore the AC. */ public DiskCacheClient( - Path root, boolean verifyDownloads, boolean checkActionResult, DigestUtil digestUtil) { + Path root, boolean verifyDownloads, boolean checkActionResult, DigestUtil digestUtil) throws IOException { this.verifyDownloads = verifyDownloads; this.checkActionResult = checkActionResult; this.digestUtil = digestUtil; @@ -71,6 +71,8 @@ public DiskCacheClient( root.getChild( Ascii.toLowerCase(digestUtil.getDigestFunction().getValueDescriptor().getName())); } + + this.root.createDirectoryAndParents(); } /** Returns {@code true} if the provided {@code key} is stored in the CAS. */ diff --git a/src/tools/remote/src/main/java/com/google/devtools/build/remote/worker/OnDiskBlobStoreCache.java b/src/tools/remote/src/main/java/com/google/devtools/build/remote/worker/OnDiskBlobStoreCache.java index c67577c54b92b7..b52afe681df8cf 100644 --- a/src/tools/remote/src/main/java/com/google/devtools/build/remote/worker/OnDiskBlobStoreCache.java +++ b/src/tools/remote/src/main/java/com/google/devtools/build/remote/worker/OnDiskBlobStoreCache.java @@ -43,7 +43,8 @@ class OnDiskBlobStoreCache extends RemoteCache { .setSymlinkAbsolutePathStrategy(SymlinkAbsolutePathStrategy.Value.ALLOWED) .build(); - public OnDiskBlobStoreCache(RemoteOptions options, Path cacheDir, DigestUtil digestUtil) { + public OnDiskBlobStoreCache(RemoteOptions options, Path cacheDir, DigestUtil digestUtil) + throws IOException { super( CAPABILITIES, new DiskCacheClient(