From a9bc2ec43a0ab093b06e4909dac4ba5a8b1cfaf1 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Fri, 10 Jun 2022 16:11:14 +0100 Subject: [PATCH] add some log statements for download states, GitHub issue #145 --- .../com/muwire/core/download/NetworkDownloader.groovy | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/main/groovy/com/muwire/core/download/NetworkDownloader.groovy b/core/src/main/groovy/com/muwire/core/download/NetworkDownloader.groovy index 6e8bcf1a9..46a8a067c 100644 --- a/core/src/main/groovy/com/muwire/core/download/NetworkDownloader.groovy +++ b/core/src/main/groovy/com/muwire/core/download/NetworkDownloader.groovy @@ -192,6 +192,7 @@ class NetworkDownloader extends Downloader { protected void doCancel() { + log.info("CANCELLED:${getLogName()}") stop() synchronized(piecesFile) { piecesFileClosed = true @@ -359,6 +360,10 @@ class NetworkDownloader extends Downloader { } } } + + private String getLogName() { + file.getName() + ":" + Base64.encode(getInfoHash().getRoot()) + } class DownloadWorker implements Runnable { private final Destination destination @@ -460,7 +465,7 @@ class NetworkDownloader extends Downloader { log.log(Level.WARNING, "Exception while downloading", DataUtil.findRoot(bad)) markFailed(destination) if (!hasLiveSources() && hopelessEventFired.compareAndSet(false, true)) { - log.info("Download hopeless, removing incomplete file") + log.info("HOPELESS:${getLogName()}") incompleteFile.delete() closePiecesFile() eventBus.publish(new DownloadHopelessEvent(downloader: NetworkDownloader.this)) @@ -472,6 +477,7 @@ class NetworkDownloader extends Downloader { if (!this.cancelled) { writePieces() if (pieces.isComplete() && eventFired.compareAndSet(false, true)) { + log.info("COMPLETE:${getLogName()}") closePiecesFile() boolean confidential = NetworkDownloader.this.isConfidential()