From 631912ff436c1b6c9f5737560ea18aff264cc0f2 Mon Sep 17 00:00:00 2001 From: shartte Date: Sat, 7 Sep 2024 22:08:11 +0200 Subject: [PATCH] Fix 404 from local Maven repo skipping remaining repos (#44) --- .../neoform/runtime/downloads/DownloadManager.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/neoforged/neoform/runtime/downloads/DownloadManager.java b/src/main/java/net/neoforged/neoform/runtime/downloads/DownloadManager.java index a790f51..dd8d4be 100644 --- a/src/main/java/net/neoforged/neoform/runtime/downloads/DownloadManager.java +++ b/src/main/java/net/neoforged/neoform/runtime/downloads/DownloadManager.java @@ -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; @@ -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)