Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,18 @@ public void beforeCommand(CommandEnvironment env) throws AbruptExitException {
repositoryCache.getRepoContentsCache().setPath(toPath(repoOptions.repoContentsCache, env));
}
Path repoContentsCachePath = repositoryCache.getRepoContentsCache().getPath();
if (repoContentsCachePath != null && env.getOutputBase().startsWith(repoContentsCachePath)) {
// This is dangerous as the repo contents cache GC may delete files in the output base.
throw new AbruptExitException(
detailedExitCode(
"""
The repo contents cache [%s] is inside the output base [%s]. This can cause \
spurious failures. Disable the repo contents cache with `--repo_contents_cache=`, \
or specify `--repo_contents_cache=<path outside the output base>`.
"""
.formatted(repoContentsCachePath, env.getOutputBase()),
Code.BAD_REPO_CONTENTS_CACHE));
}
if (repoContentsCachePath != null
&& env.getWorkspace() != null
&& repoContentsCachePath.startsWith(env.getWorkspace())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,12 @@ public void beforeCommand(CommandEnvironment env) throws AbruptExitException {
boolean enableRemoteDownloader = shouldEnableRemoteDownloader(remoteOptions);

if (enableDiskCache) {
if (env.getOutputBase().startsWith(remoteOptions.diskCache)) {
// This is dangerous as the disk cache GC may delete files in the output base.
throw createOptionsExitException(
"The --disk_cache directory cannot be a subdirectory of the output base",
FailureDetails.RemoteOptions.Code.EXECUTION_WITH_INVALID_CACHE);
}
var gcIdleTask =
DiskCacheGarbageCollectorIdleTask.create(remoteOptions, env.getWorkingDirectory());
if (gcIdleTask != null) {
Expand Down