diff --git a/src/PeerInteractionCommand.cc b/src/PeerInteractionCommand.cc index a2d76af6..d0b374ee 100644 --- a/src/PeerInteractionCommand.cc +++ b/src/PeerInteractionCommand.cc @@ -81,7 +81,7 @@ bool PeerInteractionCommand::executeInternal() { peer->ipaddr.c_str(), peer->port, handshakeMessage->toString().c_str()); delete handshakeMessage; - if(e->torrentMan->getDownloadedSize() > 0) { + if(e->torrentMan->getDownloadLength() > 0) { peerConnection->sendBitfield(); } sequence = WIRED; @@ -98,7 +98,7 @@ bool PeerInteractionCommand::executeInternal() { handshakeMessage->toString().c_str()); delete handshakeMessage; peerConnection->sendHandshake(); - if(e->torrentMan->getDownloadedSize() > 0) { + if(e->torrentMan->getDownloadLength() > 0) { peerConnection->sendBitfield(); } sequence = WIRED; diff --git a/src/TorrentConsoleDownloadEngine.cc b/src/TorrentConsoleDownloadEngine.cc index 60e487fd..aa5d5413 100644 --- a/src/TorrentConsoleDownloadEngine.cc +++ b/src/TorrentConsoleDownloadEngine.cc @@ -33,10 +33,10 @@ void TorrentConsoleDownloadEngine::printStatistics() { printf("Download Completed "); } else { printf("%s/%sB %d%% DW:%.2f", - Util::llitos(torrentMan->getDownloadedSize(), true).c_str(), + Util::llitos(torrentMan->getDownloadLength(), true).c_str(), Util::llitos(torrentMan->totalSize, true).c_str(), (torrentMan->totalSize == 0 ? - 0 : (int)((torrentMan->getDownloadedSize()*100)/torrentMan->totalSize)), + 0 : (int)((torrentMan->getDownloadLength()*100)/torrentMan->totalSize)), downloadSpeed/1000.0); } printf(" UP:%.2f(%s) %dpeers", diff --git a/src/TorrentMan.cc b/src/TorrentMan.cc index 0630c434..f68037d2 100644 --- a/src/TorrentMan.cc +++ b/src/TorrentMan.cc @@ -35,7 +35,7 @@ TorrentMan::TorrentMan():bitfield(NULL), peerEntryIdCounter(0), cuidCounter(0), - downloadedSize(0), uploadedSize(0), + downloadLength(0), uploadedSize(0), preDownloadedSize(0), preUploadedSize(0), deltaDownload(0), deltaUpload(0), storeDir("."), @@ -226,7 +226,7 @@ void TorrentMan::completePiece(const Piece& piece) { return; } if(!hasPiece(piece.getIndex())) { - addDownloadedSize(piece.getLength()); + addDownloadLength(piece.getLength()); } bitfield->setBit(piece.getIndex()); bitfield->unsetUseBit(piece.getIndex()); @@ -302,7 +302,7 @@ void TorrentMan::setup(string metaInfoFile) { } uploadedSize = 0; - downloadedSize = 0; + downloadLength = 0; Dictionary* topDic = (Dictionary*)MetaFileUtil::parseMetaFile(metaInfoFile); const Dictionary* infoDic = (const Dictionary*)topDic->get("info"); ShaVisitor v; @@ -445,13 +445,13 @@ void TorrentMan::read(FILE* file) { throw new DlAbortEx(strerror(errno)); } setBitfield(savedBitfield, bitfield->getBitfieldLength()); - if(fread(&downloadedSize, sizeof(downloadedSize), 1, file) < 1) { + if(fread(&downloadLength, sizeof(downloadLength), 1, file) < 1) { throw new DlAbortEx(strerror(errno)); } if(fread(&uploadedSize, sizeof(uploadedSize), 1, file) < 1) { throw new DlAbortEx(strerror(errno)); } - preDownloadedSize = downloadedSize; + preDownloadedSize = downloadLength; preUploadedSize = uploadedSize; delete [] savedBitfield; } catch(Exception* ex) { @@ -473,7 +473,7 @@ void TorrentMan::save() const { if(fwrite(bitfield->getBitfield(), bitfield->getBitfieldLength(), 1, file) < 1) { throw new DlAbortEx(strerror(errno)); } - if(fwrite(&downloadedSize, sizeof(downloadedSize), 1, file) < 1) { + if(fwrite(&downloadLength, sizeof(downloadLength), 1, file) < 1) { throw new DlAbortEx(strerror(errno)); } if(fwrite(&uploadedSize, sizeof(uploadedSize), 1, file) < 1) { diff --git a/src/TorrentMan.h b/src/TorrentMan.h index d8be9d69..93c506d6 100644 --- a/src/TorrentMan.h +++ b/src/TorrentMan.h @@ -73,7 +73,7 @@ private: deque pieceHashes; int peerEntryIdCounter; int cuidCounter; - long long int downloadedSize; + long long int downloadLength; long long int uploadedSize; long long int preDownloadedSize; long long int preUploadedSize; @@ -181,16 +181,16 @@ public: int getDeltaUpload() const { return deltaUpload; } void resetDeltaUpload() { deltaUpload = 0; } - void addDownloadedSize(int size) { downloadedSize += size; } - long long int getDownloadedSize() const { return downloadedSize; } - void setDownloadedSize(long long int size) { downloadedSize = size; } + void addDownloadLength(int deltaLength) { downloadLength += deltaLength; } + long long int getDownloadLength() const { return downloadLength; } + void setDownloadLength(long long int length) { downloadLength = length; } void addUploadedSize(int size) { uploadedSize += size; } long long int getUploadedSize() const { return uploadedSize; } void setUploadedSize(long long int size) { uploadedSize = size; } long long int getSessionDownloadedSize() const { - return downloadedSize-preDownloadedSize; + return downloadLength-preDownloadedSize; } long long int getSessionUploadedSize() const { return uploadedSize-preUploadedSize; diff --git a/src/TrackerInitCommand.cc b/src/TrackerInitCommand.cc index 374a1f66..79a53e87 100644 --- a/src/TrackerInitCommand.cc +++ b/src/TrackerInitCommand.cc @@ -59,8 +59,8 @@ bool TrackerInitCommand::execute() { "port="+Util::itos(e->torrentMan->getPort())+"&"+ "uploaded="+Util::llitos(e->torrentMan->getSessionUploadedSize())+"&"+ "downloaded="+Util::llitos(e->torrentMan->getSessionDownloadedSize())+"&"+ - "left="+(e->torrentMan->totalSize-e->torrentMan->getDownloadedSize() <= 0 - ? "0" : Util::llitos(e->torrentMan->totalSize-e->torrentMan->getDownloadedSize()))+"&"+ + "left="+(e->torrentMan->totalSize-e->torrentMan->getDownloadLength() <= 0 + ? "0" : Util::llitos(e->torrentMan->totalSize-e->torrentMan->getDownloadLength()))+"&"+ "compact=1"; if(!event.empty()) { url += string("&")+"event="+event;