From ca3f2513e1b3e11ed15987f21633fb0a86dcef97 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Wed, 12 Jun 2019 22:39:00 +0100 Subject: [PATCH] sync persisting of hashlist or hashroot for active downloads --- .../groovy/com/muwire/core/download/DownloadManager.groovy | 7 ++++--- .../main/groovy/com/muwire/core/download/Downloader.groovy | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/src/main/groovy/com/muwire/core/download/DownloadManager.groovy b/core/src/main/groovy/com/muwire/core/download/DownloadManager.groovy index 4d7e2f9f..fbb51e58 100644 --- a/core/src/main/groovy/com/muwire/core/download/DownloadManager.groovy +++ b/core/src/main/groovy/com/muwire/core/download/DownloadManager.groovy @@ -124,10 +124,11 @@ public class DownloadManager { } json.destinations = destinations - if (downloader.infoHash.hashList != null) - json.hashList = Base64.encode(downloader.infoHash.hashList) + InfoHash infoHash = downloader.getInfoHash() + if (infoHash.hashList != null) + json.hashList = Base64.encode(infoHash.hashList) else - json.hashRoot = Base64.encode(downloader.infoHash.getRoot()) + json.hashRoot = Base64.encode(infoHash.getRoot()) writer.println(JsonOutput.toJson(json)) } } diff --git a/core/src/main/groovy/com/muwire/core/download/Downloader.groovy b/core/src/main/groovy/com/muwire/core/download/Downloader.groovy index 1ae0f774..67396f57 100644 --- a/core/src/main/groovy/com/muwire/core/download/Downloader.groovy +++ b/core/src/main/groovy/com/muwire/core/download/Downloader.groovy @@ -76,7 +76,7 @@ public class Downloader { claimed = new Pieces(nPieces) } - private synchronized InfoHash getInfoHash() { + public synchronized InfoHash getInfoHash() { infoHash }