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

View File

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