retry download workers on resume

This commit is contained in:
Zlatin Balevsky
2019-06-04 23:36:57 +01:00
parent 7704c73b68
commit e5c402a400
2 changed files with 10 additions and 2 deletions

View File

@@ -156,7 +156,13 @@ public class Downloader {
}
public void resume() {
downloadManager.resume(this)
activeWorkers.each { destination, worker ->
if (worker.currentState == WorkerState.FINISHED) {
def newWorker = new DownloadWorker(destination)
activeWorkers.put(destination, newWorker)
executorService.submit(newWorker)
}
}
}
class DownloadWorker implements Runnable {

View File

@@ -110,7 +110,9 @@ class MainFrameModel {
lastRetryTime = now
runInsideUIAsync {
downloads.each {
if (it.downloader.currentState == Downloader.DownloadState.FAILED)
def state = it.downloader.currentState
if (state == Downloader.DownloadState.FAILED ||
state == Downloader.DownloadState.DOWNLOADING)
it.downloader.resume()
updateTablePreservingSelection("downloads-table")
}