Skip to content

Commit 3f680c6

Browse files
authored
Retry failed archive downloads
Fixes #86
1 parent ae53f17 commit 3f680c6

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/Download.java

+19-2
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,25 @@ void downloadArchive(boolean dryRun) throws Exception {
172172
if (dryRun) {
173173
return;
174174
}
175-
var response = browser.download(uri, archive);
176-
GitHub.debug(response.toString());
175+
int retry = 0;
176+
while (true) {
177+
try {
178+
GitHub.debug("Downloading " + uri);
179+
var response = browser.download(uri, archive);
180+
GitHub.debug(response.toString());
181+
return;
182+
} catch (IOException exception) {
183+
var message = Optional.ofNullable(exception.getMessage()).orElseGet(exception::toString);
184+
if (++retry == 3) {
185+
GitHub.error("Download failed due to: " + message);
186+
throw exception;
187+
}
188+
var seconds = retry * 10;
189+
GitHub.warn(String.format("Retrying in %d seconds due to: %s", seconds, message));
190+
//noinspection BusyWait
191+
Thread.sleep(seconds * 1000L);
192+
}
193+
}
177194
}
178195

179196
void verifyChecksums(String checksum) throws Exception {

0 commit comments

Comments
 (0)