Skip to content

Commit

Permalink
Fix 404 from local Maven repo skipping remaining repos (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte authored Sep 7, 2024
1 parent 07197e7 commit 631912f
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.time.Instant;
Expand Down Expand Up @@ -71,7 +72,13 @@ public boolean download(DownloadSpec spec, Path finalLocation, boolean silent) t
if (url.getScheme().equals("file")) {
// File system download (e.g. from maven local)
var fileInRepo = Path.of(url);
Files.copy(fileInRepo, partialFile, StandardCopyOption.REPLACE_EXISTING);
try {
Files.copy(fileInRepo, partialFile, StandardCopyOption.REPLACE_EXISTING);
} catch (NoSuchFileException e) {
// Translate the NIO exception since we handle 404 errors by throwing FileNotFoundException
// and callers of this method should get the same exception for 404 regardless of protocol.
throw new FileNotFoundException(e.getMessage());
}
} else {
var request = HttpRequest.newBuilder(url)
.header("User-Agent", USER_AGENT)
Expand Down

0 comments on commit 631912f

Please sign in to comment.