mirror of https://github.com/zlatinb/muwire
lock persisting of downloader, trying to fix GitHub issue #124
parent
39e21dd57d
commit
50333d10a3
|
@ -270,7 +270,7 @@ public class DownloadManager {
|
|||
persistDownloaders()
|
||||
}
|
||||
|
||||
void persistDownloaders() {
|
||||
synchronized void persistDownloaders() {
|
||||
File downloadsFile = new File(home,"downloads.json")
|
||||
downloadsFile.withPrintWriter { writer ->
|
||||
downloaders.values().each { downloader ->
|
||||
|
|
|
@ -348,7 +348,7 @@ class NetworkDownloader extends Downloader {
|
|||
}
|
||||
|
||||
public void run() {
|
||||
if (cancelled) {
|
||||
if (this.cancelled) {
|
||||
currentState = WorkerState.FINISHED
|
||||
return
|
||||
}
|
||||
|
@ -421,7 +421,7 @@ class NetworkDownloader extends Downloader {
|
|||
} catch (DownloadRejectedException rejected) {
|
||||
this.rejected = true
|
||||
} catch (Exception bad) {
|
||||
if (!cancelled) {
|
||||
if (!this.cancelled) {
|
||||
log.log(Level.WARNING, "Exception while downloading", DataUtil.findRoot(bad))
|
||||
markFailed(destination)
|
||||
if (!hasLiveSources() && hopelessEventFired.compareAndSet(false, true)) {
|
||||
|
@ -434,7 +434,7 @@ class NetworkDownloader extends Downloader {
|
|||
} finally {
|
||||
currentState = WorkerState.FINISHED
|
||||
try {
|
||||
if (!cancelled) {
|
||||
if (!this.cancelled) {
|
||||
writePieces()
|
||||
if (pieces.isComplete() && eventFired.compareAndSet(false, true)) {
|
||||
closePiecesFile()
|
||||
|
@ -461,7 +461,7 @@ class NetworkDownloader extends Downloader {
|
|||
}
|
||||
|
||||
void cancel() {
|
||||
cancelled = true
|
||||
this.cancelled = true
|
||||
downloadThread?.interrupt()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue