lock persisting of downloader, trying to fix GitHub issue #124

dbus-notify
Zlatin Balevsky 2022-03-12 13:19:51 +00:00
parent 39e21dd57d
commit 50333d10a3
No known key found for this signature in database
GPG Key ID: A72832072D525E41
2 changed files with 5 additions and 5 deletions

View File

@ -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 ->

View File

@ -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()
}
}