|
1 | 1 | package me.itzg.helpers.fabric;
|
2 | 2 |
|
| 3 | +import java.io.IOException; |
3 | 4 | import java.nio.file.Path;
|
| 5 | +import java.time.Duration; |
4 | 6 | import java.util.List;
|
5 | 7 | import java.util.function.Predicate;
|
| 8 | +import lombok.Setter; |
6 | 9 | import me.itzg.helpers.errors.GenericException;
|
7 | 10 | import me.itzg.helpers.http.FileDownloadStatusHandler;
|
8 | 11 | import me.itzg.helpers.http.SharedFetch;
|
9 | 12 | import me.itzg.helpers.http.UriBuilder;
|
10 | 13 | import org.jetbrains.annotations.NotNull;
|
11 | 14 | import org.jetbrains.annotations.Nullable;
|
12 | 15 | import reactor.core.publisher.Mono;
|
| 16 | +import reactor.util.retry.Retry; |
13 | 17 |
|
14 | 18 | public class FabricMetaClient {
|
15 | 19 |
|
16 | 20 | private final SharedFetch sharedFetch;
|
17 | 21 | private final UriBuilder uriBuilder;
|
| 22 | + @Setter |
| 23 | + private int downloadRetryMaxAttempts = 5; |
| 24 | + @Setter |
| 25 | + private Duration downloadRetryMinBackoff = Duration.ofMillis(500); |
18 | 26 |
|
19 | 27 | public FabricMetaClient(SharedFetch sharedFetch, String fabricMetaBaseUrl) {
|
20 | 28 | this.sharedFetch = sharedFetch;
|
@@ -106,7 +114,9 @@ public Mono<Path> downloadLauncher(
|
106 | 114 | )
|
107 | 115 | .toDirectory(outputDir)
|
108 | 116 | .handleStatus(statusHandler)
|
109 |
| - .assemble(); |
| 117 | + .assemble() |
| 118 | + .retryWhen(Retry.backoff(downloadRetryMaxAttempts, downloadRetryMinBackoff).filter(IOException.class::isInstance)) |
| 119 | + .checkpoint("downloadLauncher"); |
110 | 120 | }
|
111 | 121 |
|
112 | 122 | @NotNull
|
|
0 commit comments