From 67614051d46ed186bc5358a46b826da2c63d6655 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sun, 7 Sep 2025 21:00:08 -0500 Subject: [PATCH] cf: default file download retries is 5 and now configurable --- .../helpers/curseforge/CurseForgeInstaller.java | 15 ++++++++++----- .../curseforge/InstallCurseForgeCommand.java | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/main/java/me/itzg/helpers/curseforge/CurseForgeInstaller.java b/src/main/java/me/itzg/helpers/curseforge/CurseForgeInstaller.java index 849ca680..5c82b1fd 100644 --- a/src/main/java/me/itzg/helpers/curseforge/CurseForgeInstaller.java +++ b/src/main/java/me/itzg/helpers/curseforge/CurseForgeInstaller.java @@ -81,8 +81,6 @@ public class CurseForgeInstaller { public static final String REPO_SUBDIR_MODPACKS = "modpacks"; public static final String REPO_SUBDIR_MODS = "mods"; public static final String REPO_SUBDIR_WORLDS = "worlds"; - private static final Duration BAD_FILE_DELAY = Duration.ofSeconds(5); - public static final int BAD_FILE_ATTEMPTS = 3; private final Path outputDir; private final Path resultsFile; @@ -138,6 +136,12 @@ public class CurseForgeInstaller { @Getter @Setter int maxConcurrentDownloads; + @Getter @Setter + int fileDownloadRetries = 5; + + @Getter @Setter + Duration fileDownloadRetryMinDelay = Duration.ofSeconds(5); + /** */ public void installFromModpackZip(Path modpackZip, String slug) { @@ -776,7 +780,7 @@ private Mono buildRetryableDownload(InstallContext con ) // retry the deferred part above if one of the expected failure cases .retryWhen( - Retry.backoff(BAD_FILE_ATTEMPTS, BAD_FILE_DELAY) + Retry.backoff(fileDownloadRetries, fileDownloadRetryMinDelay) .filter(throwable -> throwable instanceof FileHashInvalidException || throwable instanceof FailedRequestException || @@ -784,10 +788,11 @@ private Mono buildRetryableDownload(InstallContext con throwable instanceof ChannelException ) .doBeforeRetry(retrySignal -> - log.warn("Retry #{} download of {} @ {}:{} due to {}", + log.warn("Retry #{} download of {} @ {}:{} due to {}: {}", retrySignal.totalRetries() + 1, cfFile.getFileName(), modInfo.getName(), cfFile.getDisplayName(), - retrySignal.failure().getClass().getSimpleName() + retrySignal.failure().getClass().getSimpleName(), + retrySignal.failure().getMessage() ) ) ); diff --git a/src/main/java/me/itzg/helpers/curseforge/InstallCurseForgeCommand.java b/src/main/java/me/itzg/helpers/curseforge/InstallCurseForgeCommand.java index 4eea9a48..6b0e65cd 100644 --- a/src/main/java/me/itzg/helpers/curseforge/InstallCurseForgeCommand.java +++ b/src/main/java/me/itzg/helpers/curseforge/InstallCurseForgeCommand.java @@ -7,6 +7,7 @@ import java.io.PrintWriter; import java.nio.file.Files; import java.nio.file.Path; +import java.time.Duration; import java.util.List; import java.util.Set; import java.util.concurrent.Callable; @@ -176,6 +177,16 @@ static class Listed { ) int maxConcurrentDownloads; + @Option(names = "--file-download-retries", paramLabel = "COUNT", + description = "Default is ${DEFAULT-VALUE}" + ) + int fileDownloadRetries = 5; + + @Option(names = "--file-download-retry-min-delay", paramLabel = "DURATION", + description = "Default is ${DEFAULT-VALUE}" + ) + Duration fileDownloadRetryMinDelay = Duration.ofSeconds(5); + @Override public Integer call() throws Exception { // https://www.curseforge.com/minecraft/modpacks/all-the-mods-8/files @@ -214,7 +225,9 @@ public Integer call() throws Exception { .setDisableApiCaching(disableApiCaching) .setCacheArgs(cacheArgs) .setForgeUrlArgs(forgeUrlArgs) - .setMaxConcurrentDownloads(maxConcurrentDownloads); + .setMaxConcurrentDownloads(maxConcurrentDownloads) + .setFileDownloadRetries(fileDownloadRetries) + .setFileDownloadRetryMinDelay(fileDownloadRetryMinDelay); if (apiBaseUrl != null) { installer.setApiBaseUrl(apiBaseUrl);