Tatsuhiro Tsujikawa 19 سال پیش
والد
کامیت
8ad0037ee2
2فایلهای تغییر یافته به همراه4 افزوده شده و 2 حذف شده
  1. 3 1
      src/TorrentMan.cc
  2. 1 1
      src/TrackerInitCommand.cc

+ 3 - 1
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);

+ 1 - 1
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;