Speed up mass resume/retry of downloads. GitHub issue #89

auto-update
Zlatin Balevsky 2021-10-15 02:11:39 +01:00
parent 6b105f96bb
commit bc4f61bcdb
No known key found for this signature in database
GPG Key ID: A72832072D525E41
2 changed files with 18 additions and 16 deletions

View File

@ -220,22 +220,24 @@ class NetworkDownloader extends Downloader {
}
protected void doResume() {
readPieces()
destinations.stream().filter({!isHopeless(it)}).forEach { destination ->
log.fine("resuming source ${destination.toBase32()}")
def worker = activeWorkers.get(destination)
if (worker != null) {
if (worker.currentState == WorkerState.FINISHED) {
def newWorker = new DownloadWorker(destination)
activeWorkers.put(destination, newWorker)
executorService.submit(newWorker)
executorService.submit {
readPieces()
destinations.stream().filter({ !isHopeless(it) }).forEach { destination ->
log.fine("resuming source ${destination.toBase32()}")
def worker = activeWorkers.get(destination)
if (worker != null) {
if (worker.currentState == WorkerState.FINISHED) {
def newWorker = new DownloadWorker(destination)
activeWorkers.put(destination, newWorker)
executorService.submit(newWorker)
}
} else {
worker = new DownloadWorker(destination)
activeWorkers.put(destination, worker)
executorService.submit(worker)
}
} else {
worker = new DownloadWorker(destination)
activeWorkers.put(destination, worker)
executorService.submit(worker)
}
}
} as Runnable
}
void addSource(Destination d) {

View File

@ -340,8 +340,8 @@ class MainFrameModel {
if (state == Downloader.DownloadState.FAILED ||
state == Downloader.DownloadState.DOWNLOADING)
it.downloader.resume()
updateTablePreservingSelection("downloads-table")
}
updateTablePreservingSelection("downloads-table")
}
}
@ -654,7 +654,7 @@ class MainFrameModel {
results.values().each { MVCGroup group ->
if (group.alive) {
group.view.pane.getClientProperty("results-table")?.model.fireTableDataChanged()
group.view.refreshResults()
}
}
}