From ed12d78a48ec85a5829277af0bbbe747034a9164 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Fri, 21 Jun 2019 17:22:55 +0100 Subject: [PATCH] clear pieces on cancel --- .../main/groovy/com/muwire/core/download/Downloader.groovy | 1 + core/src/main/groovy/com/muwire/core/download/Pieces.groovy | 5 +++++ 2 files changed, 6 insertions(+) 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 402138c5..6e80ebba 100644 --- a/core/src/main/groovy/com/muwire/core/download/Downloader.groovy +++ b/core/src/main/groovy/com/muwire/core/download/Downloader.groovy @@ -180,6 +180,7 @@ public class Downloader { piecesFile.delete() } incompleteFile.delete() + pieces.clearAll() } void stop() { diff --git a/core/src/main/groovy/com/muwire/core/download/Pieces.groovy b/core/src/main/groovy/com/muwire/core/download/Pieces.groovy index 243c1c14..1d947d76 100644 --- a/core/src/main/groovy/com/muwire/core/download/Pieces.groovy +++ b/core/src/main/groovy/com/muwire/core/download/Pieces.groovy @@ -78,4 +78,9 @@ class Pieces { synchronized boolean isDownloaded(int piece) { done.get(piece) } + + synchronized void clearAll() { + done.clear() + claimed.clear() + } }