mirror of
https://github.com/aria2/aria2.git
synced 2025-01-24 10:41:18 +00:00
cd91e2ea4f
* src/Xml2MetalinkProcessor.h (xpathExists): New function. * src/Xml2MetalinkProcessor.cc (xpathExists): New function. Not to send HEAD request if filename and size are available in Metalink file: * src/UrlRequestInfo.h (filename): New variable. (totalLength): New variable. (setTotalLength): New function. (setFilename): New function. * src/MetalinkRequestInfo.cc (execute): Set filename and size to UrlRequestInfo. * src/MetalinkEntry.cc (MetalinkEntry): Initialize size with 0. * src/UrlRequestInfo.cc (execute): Set filename and size to SegmentMan. Not to download rest of the files after selected files are downloaded in BitTorrent: * src/PieceStorage.h (allDownloadFinished): New function. * src/DefaultBtAnnounce.cc (isCompleteAnnounceReady): Use allDownloadFinished instead of downloadFinished. (getAnnounceUrl): Use allDownloadFinished instead of downloadFinished. * src/DefaultPieceStorage.cc (completePiece): Use allDownloadFinished instead of downloadFinished. Commented out the call to finishSelectiveDownloadingMode(). (downloadFinished): Call isFilteredAllBitSet() instead of isAllBitSet(). (allDownloadFinished): New function. * src/DefaultBtInteractive.cc (addBitfieldMessageToQueue): Call allDownloadFinished() instead of downloadFinished(). (checkHave): Call allDownloadFinished() instead of downloadFinished(). * src/TorrentDownloadEngine.cc (onEndOfRun): Call allDownloadFinished() instead of downloadFinished(). * src/BitfieldMan.h (isFilteredAllBitSet): New function. * src/ShareRatioSeedCriteria.h (PieceStorage.h): New include. (pieceStorage): New variable. (evaluate): btContext->getTotalLength() -> pieceStorage->getCompletedLength() * src/BitfieldMan.cc (isFilteredAllBitSet): New function. (isAllBitSet): Filter is not took into account. Rename --force-truncate as --allow-overwrite: * src/TorrentRequestInfo.cc (execute): PREF_FORCE_TRUNCATE -> PREF_ALLOW_OVERWRITE * src/main.cc (showUsage): --force-truncate -> --allow-overwrite * src/message.h (EX_FILE_ALREADY_EXISTS): --force-truncate -> --allow-overwrite * src/prefs.h (PREF_FORCE_TRUNCATE): Removed. (PREF_ALLOW_OVERWRITE): New definition. * src/SegmentMan.cc (shouldCancelDownloadForSafety): --force-truncate -> --allow-overwrite * src/MetalinkRequestInfo.cc (execute): Queueing message are now logged in info level. * src/common.h (LONG_LONG_MAX): Removed. (LONG_LONG_MIN): Removed. * src/HttpResponseCommand.cc (handleDefaultEncoding): LONG_LONG_MAX -> INT64_MAX * src/FtpNegotiateCommand.cc (recvSize): LONG_LONG_MAX -> INT64_MAX * src/main.cc (showUsage): Added --check-integiry and --realtime-chunk-checksum command-line option. (main): Added --check-integiry and --realtime-chunk-checksum command-line option. --force-truncate -> --allow-overwrite Set initial value of --check-integrity option to false. Don't show usage when error occurs while persing command-line options. Removed deprecated --upload-limit option.
162 lines
3.5 KiB
C++
162 lines
3.5 KiB
C++
#ifndef _D_MOCK_PIECE_STORAGE_H_
|
|
#define _D_MOCK_PIECE_STORAGE_H_
|
|
|
|
#include "PieceStorage.h"
|
|
#include "BitfieldMan.h"
|
|
|
|
class MockPieceStorage : public PieceStorage {
|
|
private:
|
|
int64_t totalLength;
|
|
int64_t filteredTotalLength;
|
|
int64_t completedLength;
|
|
int64_t filteredCompletedLength;
|
|
BitfieldMan* bitfieldMan;
|
|
bool selectiveDownloadingMode;
|
|
bool endGame;
|
|
DiskAdaptorHandle diskAdaptor;
|
|
Integers pieceLengthList;
|
|
public:
|
|
MockPieceStorage():diskAdaptor(0) {}
|
|
virtual ~MockPieceStorage() {}
|
|
|
|
virtual bool hasMissingPiece(const PeerHandle& peer) {
|
|
return false;
|
|
}
|
|
|
|
virtual PieceHandle getMissingPiece(const PeerHandle& peer) {
|
|
return new Piece();
|
|
}
|
|
|
|
virtual PieceHandle getMissingFastPiece(const PeerHandle& peer) {
|
|
return new Piece();
|
|
}
|
|
|
|
virtual PieceHandle getPiece(int index) {
|
|
return new Piece();
|
|
}
|
|
|
|
virtual void completePiece(const PieceHandle& piece) {}
|
|
|
|
virtual void cancelPiece(const PieceHandle& piece) {}
|
|
|
|
virtual bool hasPiece(int index) {
|
|
return false;
|
|
}
|
|
|
|
virtual int64_t getTotalLength() {
|
|
return totalLength;
|
|
}
|
|
|
|
void setTotalLength(int64_t totalLength) {
|
|
this->totalLength = totalLength;
|
|
}
|
|
|
|
virtual int64_t getFilteredTotalLength() {
|
|
return filteredTotalLength;
|
|
}
|
|
|
|
void setFilteredTotalLength(int64_t totalLength) {
|
|
this->filteredTotalLength = totalLength;
|
|
}
|
|
|
|
virtual int64_t getCompletedLength() {
|
|
return completedLength;
|
|
}
|
|
|
|
void setCompletedLength(int64_t completedLength) {
|
|
this->completedLength = completedLength;
|
|
}
|
|
|
|
virtual int64_t getFilteredCompletedLength() {
|
|
return filteredCompletedLength;
|
|
}
|
|
|
|
void setFilteredCompletedLength(int64_t completedLength) {
|
|
this->filteredCompletedLength = completedLength;
|
|
}
|
|
|
|
virtual void setFileFilter(const Strings& filePaths) {}
|
|
|
|
virtual void setFileFilter(const Integers& fileIndexes) {}
|
|
|
|
virtual void clearFileFilter() {}
|
|
|
|
virtual bool downloadFinished() {
|
|
return false;
|
|
}
|
|
|
|
virtual bool allDownloadFinished() {
|
|
return false;
|
|
}
|
|
|
|
virtual void initStorage() {}
|
|
|
|
virtual const unsigned char* getBitfield() {
|
|
return bitfieldMan->getBitfield();
|
|
}
|
|
|
|
virtual void setBitfield(const unsigned char* bitfield,
|
|
int32_t bitfieldLength) {
|
|
bitfieldMan->setBitfield(bitfield, bitfieldLength);
|
|
}
|
|
|
|
virtual int32_t getBitfieldLength() {
|
|
return bitfieldMan->getBitfieldLength();
|
|
}
|
|
|
|
void setBitfield(BitfieldMan* bitfieldMan) {
|
|
this->bitfieldMan = bitfieldMan;
|
|
}
|
|
|
|
virtual bool isSelectiveDownloadingMode() {
|
|
return selectiveDownloadingMode;
|
|
}
|
|
|
|
void setSelectiveDownloadingMode(bool flag) {
|
|
this->selectiveDownloadingMode = flag;
|
|
}
|
|
|
|
virtual void finishSelectiveDownloadingMode() {}
|
|
|
|
virtual bool isEndGame() {
|
|
return endGame;
|
|
}
|
|
|
|
void setEndGame(bool flag) {
|
|
this->endGame = flag;
|
|
}
|
|
|
|
virtual DiskAdaptorHandle getDiskAdaptor() {
|
|
return diskAdaptor;
|
|
}
|
|
|
|
void setDiskAdaptor(const DiskAdaptorHandle adaptor) {
|
|
this->diskAdaptor = adaptor;
|
|
}
|
|
|
|
virtual int32_t getPieceLength(int32_t index) {
|
|
return pieceLengthList.at(index);
|
|
}
|
|
|
|
void addPieceLengthList(int32_t length) {
|
|
pieceLengthList.push_back(length);
|
|
}
|
|
|
|
virtual void advertisePiece(int32_t cuid, int32_t index) {}
|
|
|
|
virtual Integers getAdvertisedPieceIndexes(int32_t myCuid,
|
|
const Time& lastCheckTime) {
|
|
return Integers();
|
|
}
|
|
|
|
virtual void removeAdvertisedPiece(int32_t elapsed) {}
|
|
|
|
virtual void markAllPiecesDone() {}
|
|
|
|
virtual void checkIntegrity() {}
|
|
};
|
|
|
|
typedef SharedHandle<MockPieceStorage> MockPieceStorageHandle;
|
|
|
|
#endif // _D_MOCK_PIECE_STORAGE_H_
|