mirror of https://github.com/zlatinb/muwire
Speed up mass resume/retry of downloads. GitHub issue #89
parent
6b105f96bb
commit
bc4f61bcdb
|
@ -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) {
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue