retry implemented
This commit is contained in:
@@ -28,10 +28,14 @@ public class DownloadManager {
|
|||||||
|
|
||||||
|
|
||||||
public void onUIDownloadEvent(UIDownloadEvent e) {
|
public void onUIDownloadEvent(UIDownloadEvent e) {
|
||||||
def downloader = new Downloader(e.target, e.result.size,
|
def downloader = new Downloader(this, e.target, e.result.size,
|
||||||
e.result.infohash, e.result.pieceSize, connector, e.result.sender.destination,
|
e.result.infohash, e.result.pieceSize, connector, e.result.sender.destination,
|
||||||
incompletes)
|
incompletes)
|
||||||
executor.execute({downloader.download()} as Runnable)
|
executor.execute({downloader.download()} as Runnable)
|
||||||
eventBus.publish(new DownloadStartedEvent(downloader : downloader))
|
eventBus.publish(new DownloadStartedEvent(downloader : downloader))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void resume(Downloader downloader) {
|
||||||
|
executor.execute({downloader.download() as Runnable})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,6 +15,7 @@ import net.i2p.data.Destination
|
|||||||
public class Downloader {
|
public class Downloader {
|
||||||
public enum DownloadState { CONNECTING, DOWNLOADING, FAILED, CANCELLED, FINISHED }
|
public enum DownloadState { CONNECTING, DOWNLOADING, FAILED, CANCELLED, FINISHED }
|
||||||
|
|
||||||
|
private final DownloadManager downloadManager
|
||||||
private final File file
|
private final File file
|
||||||
private final Pieces pieces
|
private final Pieces pieces
|
||||||
private final long length
|
private final long length
|
||||||
@@ -31,8 +32,10 @@ public class Downloader {
|
|||||||
private volatile boolean cancelled
|
private volatile boolean cancelled
|
||||||
private volatile Thread downloadThread
|
private volatile Thread downloadThread
|
||||||
|
|
||||||
public Downloader(File file, long length, InfoHash infoHash, int pieceSizePow2, I2PConnector connector, Destination destination,
|
public Downloader(DownloadManager downloadManager, File file, long length, InfoHash infoHash,
|
||||||
|
int pieceSizePow2, I2PConnector connector, Destination destination,
|
||||||
File incompletes) {
|
File incompletes) {
|
||||||
|
this.downloadManager = downloadManager
|
||||||
this.file = file
|
this.file = file
|
||||||
this.infoHash = infoHash
|
this.infoHash = infoHash
|
||||||
this.length = length
|
this.length = length
|
||||||
@@ -112,4 +115,8 @@ public class Downloader {
|
|||||||
cancelled = true
|
cancelled = true
|
||||||
downloadThread?.interrupt()
|
downloadThread?.interrupt()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resume() {
|
||||||
|
downloadManager.resume(this)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -90,6 +90,12 @@ class MainFrameController {
|
|||||||
downloader.cancel()
|
downloader.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ControllerAction
|
||||||
|
void resume() {
|
||||||
|
def downloader = selectedDownload()
|
||||||
|
downloader.resume()
|
||||||
|
}
|
||||||
|
|
||||||
void mvcGroupInit(Map<String, String> args) {
|
void mvcGroupInit(Map<String, String> args) {
|
||||||
application.addPropertyChangeListener("core", {e->
|
application.addPropertyChangeListener("core", {e->
|
||||||
core = e.getNewValue()
|
core = e.getNewValue()
|
||||||
|
@@ -99,7 +99,7 @@ class MainFrameView {
|
|||||||
}
|
}
|
||||||
panel (constraints : BorderLayout.SOUTH) {
|
panel (constraints : BorderLayout.SOUTH) {
|
||||||
button(text: "Cancel", enabled : bind {model.cancelButtonEnabled }, cancelAction )
|
button(text: "Cancel", enabled : bind {model.cancelButtonEnabled }, cancelAction )
|
||||||
button("Retry", enabled : bind {model.retryButtonEnabled})
|
button(text: "Retry", enabled : bind {model.retryButtonEnabled}, resumeAction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user