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