mirror of https://github.com/zlatinb/muwire
retry failed downloads, every 15 minutes by default
parent
f41cc39659
commit
d2533cc4d6
|
@ -6,6 +6,7 @@ class MuWireSettings {
|
|||
|
||||
final boolean isLeaf
|
||||
boolean allowUntrusted
|
||||
int downloadRetryInterval
|
||||
String nickname
|
||||
File downloadLocation
|
||||
String sharedFiles
|
||||
|
@ -23,6 +24,7 @@ class MuWireSettings {
|
|||
downloadLocation = new File((String)props.getProperty("downloadLocation",
|
||||
System.getProperty("user.home")))
|
||||
sharedFiles = props.getProperty("sharedFiles")
|
||||
downloadRetryInterval = Integer.parseInt(props.getProperty("downloadRetryInterval","15"))
|
||||
}
|
||||
|
||||
void write(OutputStream out) throws IOException {
|
||||
|
@ -32,6 +34,7 @@ class MuWireSettings {
|
|||
props.setProperty("crawlerResponse", crawlerResponse.toString())
|
||||
props.setProperty("nickname", nickname)
|
||||
props.setProperty("downloadLocation", downloadLocation.getAbsolutePath())
|
||||
props.setProperty("downloadRetryInterval", "15")
|
||||
if (sharedFiles != null)
|
||||
props.setProperty("sharedFiles", sharedFiles)
|
||||
props.store(out, "")
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.muwire.core.connection.ConnectionAttemptStatus
|
|||
import com.muwire.core.connection.ConnectionEvent
|
||||
import com.muwire.core.connection.DisconnectionEvent
|
||||
import com.muwire.core.download.DownloadStartedEvent
|
||||
import com.muwire.core.download.Downloader
|
||||
import com.muwire.core.files.FileHashedEvent
|
||||
import com.muwire.core.files.FileLoadedEvent
|
||||
import com.muwire.core.files.FileSharedEvent
|
||||
|
@ -56,6 +57,21 @@ class MainFrameModel {
|
|||
volatile Core core
|
||||
|
||||
void mvcGroupInit(Map<String, Object> args) {
|
||||
|
||||
Timer timer = new Timer("download-pumper", true)
|
||||
timer.schedule({
|
||||
runInsideUIAsync {
|
||||
if (!mvcGroup.alive)
|
||||
return
|
||||
builder.getVariable("uploads-table")?.model.fireTableDataChanged()
|
||||
|
||||
def downloadTable = builder.getVariable("downloads-table")
|
||||
int selectedRow = downloadTable.getSelectedRow()
|
||||
downloadTable.model.fireTableDataChanged()
|
||||
downloadTable.selectionModel.setSelectionInterval(selectedRow,selectedRow)
|
||||
}
|
||||
}, 1000, 1000)
|
||||
|
||||
application.addPropertyChangeListener("core", {e ->
|
||||
coreInitialized = (e.getNewValue() != null)
|
||||
core = e.getNewValue()
|
||||
|
@ -70,20 +86,21 @@ class MainFrameModel {
|
|||
core.eventBus.register(UploadFinishedEvent.class, this)
|
||||
core.eventBus.register(TrustEvent.class, this)
|
||||
core.eventBus.register(QueryEvent.class, this)
|
||||
})
|
||||
Timer timer = new Timer("download-pumper", true)
|
||||
timer.schedule({
|
||||
runInsideUIAsync {
|
||||
if (!mvcGroup.alive)
|
||||
return
|
||||
builder.getVariable("uploads-table")?.model.fireTableDataChanged()
|
||||
|
||||
def downloadTable = builder.getVariable("downloads-table")
|
||||
int selectedRow = downloadTable.getSelectedRow()
|
||||
downloadTable.model.fireTableDataChanged()
|
||||
downloadTable.selectionModel.setSelectionInterval(selectedRow,selectedRow)
|
||||
|
||||
int retryInterval = application.context.get("muwire-settings").downloadRetryInterval
|
||||
if (retryInterval > 0) {
|
||||
retryInterval *= 60000
|
||||
timer.schedule({
|
||||
runInsideUIAsync {
|
||||
downloads.each {
|
||||
if (it.downloader.currentState == Downloader.DownloadState.FAILED)
|
||||
it.downloader.resume()
|
||||
}
|
||||
}
|
||||
}, retryInterval, retryInterval)
|
||||
}
|
||||
}, 1000, 1000)
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
void onUIResultEvent(UIResultEvent e) {
|
||||
|
|
Loading…
Reference in New Issue