hook up download retry logic
This commit is contained in:
@@ -119,6 +119,7 @@ public class Downloader {
|
||||
}
|
||||
|
||||
public void resume() {
|
||||
currentState = DownloadState.CONNECTING
|
||||
downloadManager.resume(this)
|
||||
}
|
||||
}
|
||||
|
@@ -59,6 +59,8 @@ class MainFrameModel {
|
||||
|
||||
volatile Core core
|
||||
|
||||
private long lastRetryTime = System.currentTimeMillis()
|
||||
|
||||
void updateTablePreservingSelection(String tableName) {
|
||||
def downloadTable = builder.getVariable(tableName)
|
||||
int selectedRow = downloadTable.getSelectedRow()
|
||||
@@ -96,18 +98,24 @@ class MainFrameModel {
|
||||
core.eventBus.register(TrustEvent.class, this)
|
||||
core.eventBus.register(QueryEvent.class, this)
|
||||
|
||||
timer.schedule({
|
||||
int retryInterval = application.context.get("muwire-settings").downloadRetryInterval
|
||||
if (retryInterval > 0) {
|
||||
retryInterval *= 60000
|
||||
timer.schedule({
|
||||
long now = System.currentTimeMillis()
|
||||
if (now - lastRetryTime > retryInterval) {
|
||||
lastRetryTime = now
|
||||
runInsideUIAsync {
|
||||
downloads.each {
|
||||
if (it.downloader.currentState == Downloader.DownloadState.FAILED)
|
||||
it.downloader.resume()
|
||||
updateTablePreservingSelection("downloads-table")
|
||||
}
|
||||
}
|
||||
}, retryInterval, retryInterval)
|
||||
|
||||
}
|
||||
}
|
||||
}, 60000, 60000)
|
||||
|
||||
runInsideUIAsync {
|
||||
trusted.addAll(core.trustService.good.values())
|
||||
|
Reference in New Issue
Block a user