Skip to content

Commit bc56415

Browse files
authored
fabric: retry download when IO exception (#517)
1 parent 6e228be commit bc56415

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/main/java/me/itzg/helpers/fabric/FabricLauncherInstaller.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public void installUsingVersions(
6565
resolvedLoaderVersion,
6666
resolvedInstallerVersion
6767
))
68+
.checkpoint("downloadResolvedLauncher")
6869
)
6970
)
7071
.block();

src/main/java/me/itzg/helpers/fabric/FabricMetaClient.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
11
package me.itzg.helpers.fabric;
22

3+
import java.io.IOException;
34
import java.nio.file.Path;
5+
import java.time.Duration;
46
import java.util.List;
57
import java.util.function.Predicate;
8+
import lombok.Setter;
69
import me.itzg.helpers.errors.GenericException;
710
import me.itzg.helpers.http.FileDownloadStatusHandler;
811
import me.itzg.helpers.http.SharedFetch;
912
import me.itzg.helpers.http.UriBuilder;
1013
import org.jetbrains.annotations.NotNull;
1114
import org.jetbrains.annotations.Nullable;
1215
import reactor.core.publisher.Mono;
16+
import reactor.util.retry.Retry;
1317

1418
public class FabricMetaClient {
1519

1620
private final SharedFetch sharedFetch;
1721
private final UriBuilder uriBuilder;
22+
@Setter
23+
private int downloadRetryMaxAttempts = 5;
24+
@Setter
25+
private Duration downloadRetryMinBackoff = Duration.ofMillis(500);
1826

1927
public FabricMetaClient(SharedFetch sharedFetch, String fabricMetaBaseUrl) {
2028
this.sharedFetch = sharedFetch;
@@ -106,7 +114,9 @@ public Mono<Path> downloadLauncher(
106114
)
107115
.toDirectory(outputDir)
108116
.handleStatus(statusHandler)
109-
.assemble();
117+
.assemble()
118+
.retryWhen(Retry.backoff(downloadRetryMaxAttempts, downloadRetryMinBackoff).filter(IOException.class::isInstance))
119+
.checkpoint("downloadLauncher");
110120
}
111121

112122
@NotNull

0 commit comments

Comments
 (0)