Skip to content

Commit 38ac4b0

Browse files
committed
Don't emit a warning from resolver and decoder if the file does not exist
It simply means that the file does not exist for some external reason. For example, in execroot it can be deleted because of another build. Or path might be received from provider via aspect, so it could be a provider issue.
1 parent 0adb0d1 commit 38ac4b0

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

base/src/com/google/idea/blaze/base/sync/workspace/ArtifactLocationDecoderImpl.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 The Bazel Authors. All rights reserved.
2+
* Copyright 2025 The Bazel Authors. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
2525
import com.intellij.openapi.util.io.FileUtil;
2626
import java.io.File;
2727
import java.io.IOException;
28+
import java.nio.file.Files;
2829
import java.nio.file.Path;
2930
import java.nio.file.Paths;
3031
import java.util.Objects;
@@ -93,6 +94,12 @@ public File decode(ArtifactLocation artifactLocation) {
9394
private @Nullable File tryToResolveExternalArtifactToMainWorkspace(ArtifactLocation artifactLocation) {
9495
if (artifactLocation.isExternal()) {
9596
try {
97+
Path estimatedLocation = blazeInfo.getExecutionRoot().toPath().resolve(artifactLocation.getExecutionRootRelativePath());
98+
if (!Files.exists(estimatedLocation)) {
99+
LOG.info("Cannot resolve " + estimatedLocation + " because it does not exist");
100+
return null;
101+
}
102+
96103
File realFile = blazeInfo.getExecutionRoot().toPath()
97104
.resolve(artifactLocation.getExecutionRootRelativePath()).toRealPath().toFile();
98105
if (pathResolver.getWorkspacePath(realFile) != null) {

base/src/com/google/idea/blaze/base/sync/workspace/ExecutionRootPathResolver.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 The Bazel Authors. All rights reserved.
2+
* Copyright 2025 The Bazel Authors. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,6 +28,8 @@
2828
import com.intellij.openapi.project.Project;
2929
import java.io.File;
3030
import java.io.IOException;
31+
import java.nio.file.Files;
32+
import java.nio.file.Path;
3133
import javax.annotation.Nullable;
3234
import org.jetbrains.annotations.NotNull;
3335

@@ -158,14 +160,19 @@ public ImmutableList<File> resolveToIncludeDirectories(ExecutionRootPath path) {
158160
public ImmutableList<File> resolveToExternalWorkspaceWithSymbolicLinkResolution(
159161
ExecutionRootPath path) {
160162
File fileInExecutionRoot = path.getFileRootedAt(outputBase);
161-
162-
try {
163-
File realPath = fileInExecutionRoot.toPath().toRealPath().toFile();
164-
if (workspacePathResolver.getWorkspacePath(realPath) != null) {
165-
return ImmutableList.of(realPath);
163+
Path pathInExecutionRoot = fileInExecutionRoot.toPath();
164+
if (!Files.exists(pathInExecutionRoot)) {
165+
LOG.info("Cannot resolve " + pathInExecutionRoot + " because it does not exist");
166+
}
167+
else {
168+
try {
169+
File realPath = pathInExecutionRoot.toRealPath().toFile();
170+
if (workspacePathResolver.getWorkspacePath(realPath) != null) {
171+
return ImmutableList.of(realPath);
172+
}
173+
} catch (IOException ioException) {
174+
LOG.warn("Failed to resolve real path for " + fileInExecutionRoot, ioException);
166175
}
167-
} catch (IOException ioException) {
168-
LOG.warn("Failed to resolve real path for " + fileInExecutionRoot, ioException);
169176
}
170177

171178
return ImmutableList.of(fileInExecutionRoot);

0 commit comments

Comments
 (0)