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() { protected void doResume() {
readPieces() executorService.submit {
destinations.stream().filter({!isHopeless(it)}).forEach { destination -> readPieces()
log.fine("resuming source ${destination.toBase32()}") destinations.stream().filter({ !isHopeless(it) }).forEach { destination ->
def worker = activeWorkers.get(destination) log.fine("resuming source ${destination.toBase32()}")
if (worker != null) { def worker = activeWorkers.get(destination)
if (worker.currentState == WorkerState.FINISHED) { if (worker != null) {
def newWorker = new DownloadWorker(destination) if (worker.currentState == WorkerState.FINISHED) {
activeWorkers.put(destination, newWorker) def newWorker = new DownloadWorker(destination)
executorService.submit(newWorker) 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) { void addSource(Destination d) {

View File

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