|
1 | 1 | /* |
2 | | - * Copyright 2016 The Bazel Authors. All rights reserved. |
| 2 | + * Copyright 2025 The Bazel Authors. All rights reserved. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
28 | 28 | import com.intellij.openapi.project.Project; |
29 | 29 | import java.io.File; |
30 | 30 | import java.io.IOException; |
| 31 | +import java.nio.file.Files; |
| 32 | +import java.nio.file.Path; |
31 | 33 | import javax.annotation.Nullable; |
32 | 34 | import org.jetbrains.annotations.NotNull; |
33 | 35 |
|
@@ -158,14 +160,19 @@ public ImmutableList<File> resolveToIncludeDirectories(ExecutionRootPath path) { |
158 | 160 | public ImmutableList<File> resolveToExternalWorkspaceWithSymbolicLinkResolution( |
159 | 161 | ExecutionRootPath path) { |
160 | 162 | 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); |
166 | 175 | } |
167 | | - } catch (IOException ioException) { |
168 | | - LOG.warn("Failed to resolve real path for " + fileInExecutionRoot, ioException); |
169 | 176 | } |
170 | 177 |
|
171 | 178 | return ImmutableList.of(fileInExecutionRoot); |
|
0 commit comments