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()
|
persistDownloaders()
|
||||||
}
|
}
|
||||||
|
|
||||||
void persistDownloaders() {
|
synchronized void persistDownloaders() {
|
||||||
File downloadsFile = new File(home,"downloads.json")
|
File downloadsFile = new File(home,"downloads.json")
|
||||||
downloadsFile.withPrintWriter { writer ->
|
downloadsFile.withPrintWriter { writer ->
|
||||||
downloaders.values().each { downloader ->
|
downloaders.values().each { downloader ->
|
||||||
|
|
|
@ -348,7 +348,7 @@ class NetworkDownloader extends Downloader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
if (cancelled) {
|
if (this.cancelled) {
|
||||||
currentState = WorkerState.FINISHED
|
currentState = WorkerState.FINISHED
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -421,7 +421,7 @@ class NetworkDownloader extends Downloader {
|
||||||
} catch (DownloadRejectedException rejected) {
|
} catch (DownloadRejectedException rejected) {
|
||||||
this.rejected = true
|
this.rejected = true
|
||||||
} catch (Exception bad) {
|
} catch (Exception bad) {
|
||||||
if (!cancelled) {
|
if (!this.cancelled) {
|
||||||
log.log(Level.WARNING, "Exception while downloading", DataUtil.findRoot(bad))
|
log.log(Level.WARNING, "Exception while downloading", DataUtil.findRoot(bad))
|
||||||
markFailed(destination)
|
markFailed(destination)
|
||||||
if (!hasLiveSources() && hopelessEventFired.compareAndSet(false, true)) {
|
if (!hasLiveSources() && hopelessEventFired.compareAndSet(false, true)) {
|
||||||
|
@ -434,7 +434,7 @@ class NetworkDownloader extends Downloader {
|
||||||
} finally {
|
} finally {
|
||||||
currentState = WorkerState.FINISHED
|
currentState = WorkerState.FINISHED
|
||||||
try {
|
try {
|
||||||
if (!cancelled) {
|
if (!this.cancelled) {
|
||||||
writePieces()
|
writePieces()
|
||||||
if (pieces.isComplete() && eventFired.compareAndSet(false, true)) {
|
if (pieces.isComplete() && eventFired.compareAndSet(false, true)) {
|
||||||
closePiecesFile()
|
closePiecesFile()
|
||||||
|
@ -461,7 +461,7 @@ class NetworkDownloader extends Downloader {
|
||||||
}
|
}
|
||||||
|
|
||||||
void cancel() {
|
void cancel() {
|
||||||
cancelled = true
|
this.cancelled = true
|
||||||
downloadThread?.interrupt()
|
downloadThread?.interrupt()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue