Skip to content

Commit

Permalink
Respond to review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Jun 18, 2024
1 parent 75e0327 commit ebda2c3
Showing 1 changed file with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Base64;
import java.util.Collection;
import java.util.HashMap;
Expand Down Expand Up @@ -94,22 +93,16 @@ public static UrlRewriter getDownloaderUrlRewriter(Path workspaceRoot, String co
return new UrlRewriter(log, "", new StringReader(""));
}

// If the `configPath` is absolute, use that. Otherwise, prepend the `workspaceRoot`.
// There have been reports (eg. https://github.com/bazelbuild/bazel/issues/22104) that
// there are occasional errors when `configFile` can't be found, and when this happens
// investigation suggests that the current working directory isn't the workspace root.
Path actualConfigPath;
if (Paths.get(configPath).isAbsolute()) {
actualConfigPath = workspaceRoot.getFileSystem().getPath(configPath);
} else {
actualConfigPath = workspaceRoot.getRelative(configPath);
}
Path actualConfigPath = workspaceRoot.getRelative(configPath);

if (!actualConfigPath.exists()) {
throw new UrlRewriterParseException(String.format("Unable to find downloader config file %s", configPath));
}

try (BufferedReader reader = Files.newBufferedReader(Paths.get(configPath))) {
try (BufferedReader reader = Files.newBufferedReader(actualConfigPath.getPathFile().toPath())) {
return new UrlRewriter(log, configPath, reader);
} catch (IOException e) {
throw new UrlRewriterParseException(e.getMessage());
Expand Down

0 comments on commit ebda2c3

Please sign in to comment.