DownloadProgressTracker: Fix behaviour when download is done.

Currently progress() can be called after doneDownload() which should not
happen. Also make sure that we call progress() with 100% progress before we
call doneDownload() - this is in case any existing users have given up on
downDownload() being called at the right time and instead use 100% progress
as their signal that downloading is complete.
This commit is contained in:
Jon Griffiths
2016-08-25 02:01:42 +12:00
committed by Andreas Schildbach
parent 45e25167cd
commit 3403fc52c6

View File

@@ -66,8 +66,13 @@ public class DownloadProgressTracker extends AbstractPeerDataEventListener {
if (blocksLeft == 0) {
caughtUp = true;
if (lastPercent != 100) {
lastPercent = 100;
progress(lastPercent, blocksLeft, new Date(block.getTimeSeconds() * 1000));
}
doneDownload();
future.set(peer.getBestHeight());
return;
}
if (blocksLeft < 0 || originalBlocksLeft <= 0)