From 1985d407ee1ffdd2c4524fa83ec6e74adce7823e Mon Sep 17 00:00:00 2001 From: Christian Stein Date: Wed, 11 Sep 2024 18:39:28 +0200 Subject: [PATCH 1/3] Retry failed archive downloads Fixes #86 --- src/Download.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Download.java b/src/Download.java index 8f01720..f2165a6 100644 --- a/src/Download.java +++ b/src/Download.java @@ -172,8 +172,20 @@ void downloadArchive(boolean dryRun) throws Exception { if (dryRun) { return; } - var response = browser.download(uri, archive); - GitHub.debug(response.toString()); + int retries = 3; + while (true) { + try { + var response = browser.download(uri, archive); + GitHub.debug(response.toString()); + return; + } catch (IOException exception) { + if (--retries == 0) { + GitHub.error("Downloading archive failed: " + exception.getMessage()); + throw exception; + } + GitHub.warn("Retrying archive download due to: " + exception.getMessage()); + } + } } void verifyChecksums(String checksum) throws Exception { From 98cde4e3cdd38dc319ad70a4bd0823f161002071 Mon Sep 17 00:00:00 2001 From: Christian Stein Date: Wed, 11 Sep 2024 18:42:54 +0200 Subject: [PATCH 2/3] Wait some seconds before retrying --- src/Download.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Download.java b/src/Download.java index f2165a6..1fffb5d 100644 --- a/src/Download.java +++ b/src/Download.java @@ -184,6 +184,8 @@ void downloadArchive(boolean dryRun) throws Exception { throw exception; } GitHub.warn("Retrying archive download due to: " + exception.getMessage()); + //noinspection BusyWait + Thread.sleep(9 * 1000); } } } From 2476a44ce637d748231295f429a6161641466187 Mon Sep 17 00:00:00 2001 From: Christian Stein Date: Thu, 12 Sep 2024 12:11:32 +0200 Subject: [PATCH 3/3] Increase downtime per retry --- src/Download.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Download.java b/src/Download.java index 1fffb5d..ec46397 100644 --- a/src/Download.java +++ b/src/Download.java @@ -172,20 +172,23 @@ void downloadArchive(boolean dryRun) throws Exception { if (dryRun) { return; } - int retries = 3; + int retry = 0; while (true) { try { + GitHub.debug("Downloading " + uri); var response = browser.download(uri, archive); GitHub.debug(response.toString()); return; } catch (IOException exception) { - if (--retries == 0) { - GitHub.error("Downloading archive failed: " + exception.getMessage()); + var message = Optional.ofNullable(exception.getMessage()).orElseGet(exception::toString); + if (++retry == 3) { + GitHub.error("Download failed due to: " + message); throw exception; } - GitHub.warn("Retrying archive download due to: " + exception.getMessage()); + var seconds = retry * 10; + GitHub.warn(String.format("Retrying in %d seconds due to: %s", seconds, message)); //noinspection BusyWait - Thread.sleep(9 * 1000); + Thread.sleep(seconds * 1000L); } } }