From 964e315367a68313cf2ccf9b1d684c1f06157547 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Wed, 23 Sep 2020 14:17:40 +0100 Subject: [PATCH] add a hopeless state for a download where all sources are hopeless --- .../main/groovy/com/muwire/core/download/Downloader.groovy | 6 ++++-- webui/src/main/js/download.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/main/groovy/com/muwire/core/download/Downloader.groovy b/core/src/main/groovy/com/muwire/core/download/Downloader.groovy index 0bff9077..c1310fbd 100644 --- a/core/src/main/groovy/com/muwire/core/download/Downloader.groovy +++ b/core/src/main/groovy/com/muwire/core/download/Downloader.groovy @@ -31,7 +31,7 @@ import net.i2p.util.ConcurrentHashSet @Log public class Downloader { - public enum DownloadState { CONNECTING, HASHLIST, DOWNLOADING, FAILED, CANCELLED, PAUSED, FINISHED } + public enum DownloadState { CONNECTING, HASHLIST, DOWNLOADING, FAILED, HOPELESS, CANCELLED, PAUSED, FINISHED } private enum WorkerState { CONNECTING, HASHLIST, DOWNLOADING, FINISHED} private static final ExecutorService executorService = Executors.newCachedThreadPool({r -> @@ -214,6 +214,8 @@ public class Downloader { if (allFinished) { if (pieces.isComplete()) return DownloadState.FINISHED + if (!hasLiveSources()) + return DownloadState.HOPELESS return DownloadState.FAILED } @@ -284,7 +286,7 @@ public class Downloader { } } - public boolean hasLiveSources() { + private boolean hasLiveSources() { destinations.size() > countHopelessSources() } diff --git a/webui/src/main/js/download.js b/webui/src/main/js/download.js index ce654cd1..e6ba52ed 100644 --- a/webui/src/main/js/download.js +++ b/webui/src/main/js/download.js @@ -42,7 +42,7 @@ class Downloader { } getPauseResumeRetryBlock() { - if (this.state == "FINISHED" || this.state == "CANCELLED") + if (this.state == "FINISHED" || this.state == "CANCELLED" || this.state == "HOPELESS") return "" if (this.state == "FAILED") { var retryLink = new Link(_t("Retry"), "resumeDownload", [this.infoHash])