From 8ad0037ee28413f0928d6b5b8d6e3513dff118cb Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 21 Mar 2006 17:28:57 +0000 Subject: [PATCH] --- src/TorrentMan.cc | 4 +++- src/TrackerInitCommand.cc | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/TorrentMan.cc b/src/TorrentMan.cc index 688b9b7f..9e2cc82d 100644 --- a/src/TorrentMan.cc +++ b/src/TorrentMan.cc @@ -218,9 +218,11 @@ void TorrentMan::completePiece(const Piece& piece) { if(Piece::isNull(piece)) { return; } + if(!hasPiece(piece.getIndex())) { + addDownloadedSize(piece.getLength()); + } bitfield->setBit(piece.getIndex()); bitfield->unsetUseBit(piece.getIndex()); - addDownloadedSize(piece.getLength()); deleteUsedPiece(piece); if(!isEndGame()) { reduceUsedPieces(100); diff --git a/src/TrackerInitCommand.cc b/src/TrackerInitCommand.cc index 66d01b3d..1f3b05c2 100644 --- a/src/TrackerInitCommand.cc +++ b/src/TrackerInitCommand.cc @@ -51,7 +51,7 @@ bool TrackerInitCommand::execute() { "port="+Util::itos(e->torrentMan->getPort())+"&"+ "uploaded="+Util::llitos(e->torrentMan->getUploadedSize())+"&"+ "downloaded="+Util::llitos(e->torrentMan->getDownloadedSize())+"&"+ - "left="+Util::llitos(e->torrentMan->totalSize-e->torrentMan->getDownloadedSize())+"&"+ + "left="+(e->torrentMan->downloadComplete() ? "0" : Util::llitos(e->torrentMan->totalSize-e->torrentMan->getDownloadedSize()))+"&"+ "compact=1"; if(!event.empty()) { url += string("&")+"event="+event;