add a hopeless state for a download where all sources are hopeless

pull/53/head
Zlatin Balevsky 2020-09-23 14:17:40 +01:00
parent 140231e362
commit 964e315367
No known key found for this signature in database
GPG Key ID: A72832072D525E41
2 changed files with 5 additions and 3 deletions

View File

@ -31,7 +31,7 @@ import net.i2p.util.ConcurrentHashSet
@Log @Log
public class Downloader { 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 enum WorkerState { CONNECTING, HASHLIST, DOWNLOADING, FINISHED}
private static final ExecutorService executorService = Executors.newCachedThreadPool({r -> private static final ExecutorService executorService = Executors.newCachedThreadPool({r ->
@ -214,6 +214,8 @@ public class Downloader {
if (allFinished) { if (allFinished) {
if (pieces.isComplete()) if (pieces.isComplete())
return DownloadState.FINISHED return DownloadState.FINISHED
if (!hasLiveSources())
return DownloadState.HOPELESS
return DownloadState.FAILED return DownloadState.FAILED
} }
@ -284,7 +286,7 @@ public class Downloader {
} }
} }
public boolean hasLiveSources() { private boolean hasLiveSources() {
destinations.size() > countHopelessSources() destinations.size() > countHopelessSources()
} }

View File

@ -42,7 +42,7 @@ class Downloader {
} }
getPauseResumeRetryBlock() { getPauseResumeRetryBlock() {
if (this.state == "FINISHED" || this.state == "CANCELLED") if (this.state == "FINISHED" || this.state == "CANCELLED" || this.state == "HOPELESS")
return "" return ""
if (this.state == "FAILED") { if (this.state == "FAILED") {
var retryLink = new Link(_t("Retry"), "resumeDownload", [this.infoHash]) var retryLink = new Link(_t("Retry"), "resumeDownload", [this.infoHash])