mirror of https://github.com/aria2/aria2
Removed DownloadContext::dir_. Use PREF_DIR value instead.
parent
479f71efaf
commit
0a2b1660fa
|
@ -81,7 +81,6 @@ bool BtDependency::resolve()
|
||||||
// cut reference here
|
// cut reference here
|
||||||
dependee_.reset();
|
dependee_.reset();
|
||||||
SharedHandle<DownloadContext> context(new DownloadContext());
|
SharedHandle<DownloadContext> context(new DownloadContext());
|
||||||
context->setDir(dependant_->getDownloadContext()->getDir());
|
|
||||||
try {
|
try {
|
||||||
SharedHandle<DiskAdaptor> diskAdaptor =
|
SharedHandle<DiskAdaptor> diskAdaptor =
|
||||||
dependee->getPieceStorage()->getDiskAdaptor();
|
dependee->getPieceStorage()->getDiskAdaptor();
|
||||||
|
@ -91,12 +90,14 @@ bool BtDependency::resolve()
|
||||||
SharedHandle<TorrentAttribute> attrs =
|
SharedHandle<TorrentAttribute> attrs =
|
||||||
bittorrent::getTorrentAttrs(dependee->getDownloadContext());
|
bittorrent::getTorrentAttrs(dependee->getDownloadContext());
|
||||||
bittorrent::loadFromMemory
|
bittorrent::loadFromMemory
|
||||||
(bittorrent::metadata2Torrent(content, attrs), context, "default");
|
(bittorrent::metadata2Torrent(content, attrs), context,
|
||||||
|
dependant_->getOption(), "default");
|
||||||
// We don't call bittorrent::adjustAnnounceUri() because it
|
// We don't call bittorrent::adjustAnnounceUri() because it
|
||||||
// has already been called with attrs.
|
// has already been called with attrs.
|
||||||
} else {
|
} else {
|
||||||
bittorrent::loadFromMemory
|
bittorrent::loadFromMemory
|
||||||
(content, context, File(dependee->getFirstFilePath()).getBasename());
|
(content, context, dependant_->getOption(),
|
||||||
|
File(dependee->getFirstFilePath()).getBasename());
|
||||||
bittorrent::adjustAnnounceUri(bittorrent::getTorrentAttrs(context),
|
bittorrent::adjustAnnounceUri(bittorrent::getTorrentAttrs(context),
|
||||||
dependant_->getOption());
|
dependant_->getOption());
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,6 @@
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
DownloadContext::DownloadContext():
|
DownloadContext::DownloadContext():
|
||||||
dir_(A2STR::DOT_C),
|
|
||||||
pieceLength_(0),
|
pieceLength_(0),
|
||||||
checksumVerified_(false),
|
checksumVerified_(false),
|
||||||
knowsTotalLength_(true),
|
knowsTotalLength_(true),
|
||||||
|
@ -59,7 +58,6 @@ DownloadContext::DownloadContext():
|
||||||
DownloadContext::DownloadContext(size_t pieceLength,
|
DownloadContext::DownloadContext(size_t pieceLength,
|
||||||
uint64_t totalLength,
|
uint64_t totalLength,
|
||||||
const std::string& path):
|
const std::string& path):
|
||||||
dir_(A2STR::DOT_C),
|
|
||||||
pieceLength_(pieceLength),
|
pieceLength_(pieceLength),
|
||||||
checksumVerified_(false),
|
checksumVerified_(false),
|
||||||
knowsTotalLength_(true),
|
knowsTotalLength_(true),
|
||||||
|
@ -259,11 +257,6 @@ void DownloadContext::setBasePath(const std::string& basePath)
|
||||||
basePath_ = basePath;
|
basePath_ = basePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadContext::setDir(const std::string& dir)
|
|
||||||
{
|
|
||||||
dir_ = dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadContext::setSignature(const SharedHandle<Signature>& signature)
|
void DownloadContext::setSignature(const SharedHandle<Signature>& signature)
|
||||||
{
|
{
|
||||||
signature_ = signature;
|
signature_ = signature;
|
||||||
|
|
|
@ -59,8 +59,6 @@ class DownloadContext
|
||||||
private:
|
private:
|
||||||
std::vector<SharedHandle<FileEntry> > fileEntries_;
|
std::vector<SharedHandle<FileEntry> > fileEntries_;
|
||||||
|
|
||||||
std::string dir_;
|
|
||||||
|
|
||||||
std::vector<std::string> pieceHashes_;
|
std::vector<std::string> pieceHashes_;
|
||||||
|
|
||||||
size_t pieceLength_;
|
size_t pieceLength_;
|
||||||
|
@ -161,10 +159,6 @@ public:
|
||||||
|
|
||||||
void setBasePath(const std::string& basePath);
|
void setBasePath(const std::string& basePath);
|
||||||
|
|
||||||
const std::string& getDir() const { return dir_; }
|
|
||||||
|
|
||||||
void setDir(const std::string& dir);
|
|
||||||
|
|
||||||
const SharedHandle<Signature>& getSignature() const { return signature_; }
|
const SharedHandle<Signature>& getSignature() const { return signature_; }
|
||||||
|
|
||||||
void setSignature(const SharedHandle<Signature>& signature);
|
void setSignature(const SharedHandle<Signature>& signature);
|
||||||
|
|
|
@ -367,7 +367,7 @@ bool FtpNegotiationCommand::onFileSizeDetermined(uint64_t totalLength)
|
||||||
if(getFileEntry()->getPath().empty()) {
|
if(getFileEntry()->getPath().empty()) {
|
||||||
getFileEntry()->setPath
|
getFileEntry()->setPath
|
||||||
(util::createSafePath
|
(util::createSafePath
|
||||||
(getDownloadContext()->getDir(),
|
(getOption()->get(PREF_DIR),
|
||||||
util::percentDecode(getRequest()->getFile())));
|
util::percentDecode(getRequest()->getFile())));
|
||||||
}
|
}
|
||||||
getRequestGroup()->preDownloadProcessing();
|
getRequestGroup()->preDownloadProcessing();
|
||||||
|
|
|
@ -158,7 +158,7 @@ bool HttpRequestCommand::executeInternal() {
|
||||||
if(getFileEntry()->getPath().empty()) {
|
if(getFileEntry()->getPath().empty()) {
|
||||||
getFileEntry()->setPath
|
getFileEntry()->setPath
|
||||||
(util::createSafePath
|
(util::createSafePath
|
||||||
(getDownloadContext()->getDir(),
|
(getOption()->get(PREF_DIR),
|
||||||
util::percentDecode(getRequest()->getFile())));
|
util::percentDecode(getRequest()->getFile())));
|
||||||
}
|
}
|
||||||
File ctrlfile(getFileEntry()->getPath()+
|
File ctrlfile(getFileEntry()->getPath()+
|
||||||
|
|
|
@ -207,7 +207,7 @@ bool HttpResponseCommand::executeInternal()
|
||||||
if(getFileEntry()->getPath().empty()) {
|
if(getFileEntry()->getPath().empty()) {
|
||||||
getFileEntry()->setPath
|
getFileEntry()->setPath
|
||||||
(util::createSafePath
|
(util::createSafePath
|
||||||
(getDownloadContext()->getDir(), httpResponse->determinFilename()));
|
(getOption()->get(PREF_DIR), httpResponse->determinFilename()));
|
||||||
}
|
}
|
||||||
getFileEntry()->setContentType(httpResponse->getContentType());
|
getFileEntry()->setContentType(httpResponse->getContentType());
|
||||||
getRequestGroup()->preDownloadProcessing();
|
getRequestGroup()->preDownloadProcessing();
|
||||||
|
|
|
@ -309,7 +309,6 @@ Metalink2RequestGroup::createRequestGroup
|
||||||
dctx->setFileEntries(fileEntries.begin(), fileEntries.end());
|
dctx->setFileEntries(fileEntries.begin(), fileEntries.end());
|
||||||
rg->setNumConcurrentCommand(option->getAsInt(PREF_METALINK_SERVERS));
|
rg->setNumConcurrentCommand(option->getAsInt(PREF_METALINK_SERVERS));
|
||||||
}
|
}
|
||||||
dctx->setDir(option->get(PREF_DIR));
|
|
||||||
rg->setDownloadContext(dctx);
|
rg->setDownloadContext(dctx);
|
||||||
// remove "metalink" from Accept Type list to avoid loop in
|
// remove "metalink" from Accept Type list to avoid loop in
|
||||||
// tranparent metalink
|
// tranparent metalink
|
||||||
|
|
|
@ -1189,7 +1189,7 @@ DownloadResultHandle RequestGroup::createDownloadResult() const
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
res->pieceLength = downloadContext_->getPieceLength();
|
res->pieceLength = downloadContext_->getPieceLength();
|
||||||
res->numPieces = downloadContext_->getNumPieces();
|
res->numPieces = downloadContext_->getNumPieces();
|
||||||
res->dir = downloadContext_->getDir();
|
res->dir = option_->get(PREF_DIR);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -238,7 +238,6 @@ TrackerWatcherCommand::createRequestGroup(const std::string& uri)
|
||||||
(new DownloadContext(getOption()->getAsInt(PREF_SEGMENT_SIZE),
|
(new DownloadContext(getOption()->getAsInt(PREF_SEGMENT_SIZE),
|
||||||
0,
|
0,
|
||||||
TRACKER_ANNOUNCE_FILE));
|
TRACKER_ANNOUNCE_FILE));
|
||||||
dctx->setDir(A2STR::NIL);
|
|
||||||
dctx->getFileEntries().front()->setUris(uris);
|
dctx->getFileEntries().front()->setUris(uris);
|
||||||
rg->setDownloadContext(dctx);
|
rg->setDownloadContext(dctx);
|
||||||
SharedHandle<DiskWriterFactory> dwf(new ByteArrayDiskWriterFactory());
|
SharedHandle<DiskWriterFactory> dwf(new ByteArrayDiskWriterFactory());
|
||||||
|
|
|
@ -611,7 +611,7 @@ void gatherProgressCommon
|
||||||
entryDict->put(KEY_FILES, files);
|
entryDict->put(KEY_FILES, files);
|
||||||
}
|
}
|
||||||
if(requested_key(keys, KEY_DIR)) {
|
if(requested_key(keys, KEY_DIR)) {
|
||||||
entryDict->put(KEY_DIR, dctx->getDir());
|
entryDict->put(KEY_DIR, group->getOption()->get(PREF_DIR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -193,6 +193,7 @@ void extractFileEntries
|
||||||
(const SharedHandle<DownloadContext>& ctx,
|
(const SharedHandle<DownloadContext>& ctx,
|
||||||
const SharedHandle<TorrentAttribute>& torrent,
|
const SharedHandle<TorrentAttribute>& torrent,
|
||||||
const Dict* infoDict,
|
const Dict* infoDict,
|
||||||
|
const SharedHandle<Option>& option,
|
||||||
const std::string& defaultName,
|
const std::string& defaultName,
|
||||||
const std::string& overrideName,
|
const std::string& overrideName,
|
||||||
const std::vector<std::string>& urlList)
|
const std::vector<std::string>& urlList)
|
||||||
|
@ -284,7 +285,8 @@ void extractFileEntries
|
||||||
std::vector<std::string> uris;
|
std::vector<std::string> uris;
|
||||||
createUri(urlList.begin(), urlList.end(),std::back_inserter(uris),pePath);
|
createUri(urlList.begin(), urlList.end(),std::back_inserter(uris),pePath);
|
||||||
SharedHandle<FileEntry> fileEntry
|
SharedHandle<FileEntry> fileEntry
|
||||||
(new FileEntry(util::applyDir(ctx->getDir(),util::escapePath(utf8Path)),
|
(new FileEntry(util::applyDir(option->get(PREF_DIR),
|
||||||
|
util::escapePath(utf8Path)),
|
||||||
fileLengthData->i(), offset, uris));
|
fileLengthData->i(), offset, uris));
|
||||||
fileEntry->setOriginalName(path);
|
fileEntry->setOriginalName(path);
|
||||||
fileEntries.push_back(fileEntry);
|
fileEntries.push_back(fileEntry);
|
||||||
|
@ -312,14 +314,15 @@ void extractFileEntries
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SharedHandle<FileEntry> fileEntry
|
SharedHandle<FileEntry> fileEntry
|
||||||
(new FileEntry(util::applyDir(ctx->getDir(), util::escapePath(utf8Name)),
|
(new FileEntry(util::applyDir(option->get(PREF_DIR),
|
||||||
|
util::escapePath(utf8Name)),
|
||||||
totalLength, 0, uris));
|
totalLength, 0, uris));
|
||||||
fileEntry->setOriginalName(name);
|
fileEntry->setOriginalName(name);
|
||||||
fileEntries.push_back(fileEntry);
|
fileEntries.push_back(fileEntry);
|
||||||
}
|
}
|
||||||
ctx->setFileEntries(fileEntries.begin(), fileEntries.end());
|
ctx->setFileEntries(fileEntries.begin(), fileEntries.end());
|
||||||
if(torrent->mode == MULTI) {
|
if(torrent->mode == MULTI) {
|
||||||
ctx->setBasePath(util::applyDir(ctx->getDir(), utf8Name));
|
ctx->setBasePath(util::applyDir(option->get(PREF_DIR), utf8Name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -392,6 +395,7 @@ namespace {
|
||||||
void processRootDictionary
|
void processRootDictionary
|
||||||
(const SharedHandle<DownloadContext>& ctx,
|
(const SharedHandle<DownloadContext>& ctx,
|
||||||
const SharedHandle<ValueBase>& root,
|
const SharedHandle<ValueBase>& root,
|
||||||
|
const SharedHandle<Option>& option,
|
||||||
const std::string& defaultName,
|
const std::string& defaultName,
|
||||||
const std::string& overrideName,
|
const std::string& overrideName,
|
||||||
const std::vector<std::string>& uris)
|
const std::vector<std::string>& uris)
|
||||||
|
@ -466,7 +470,7 @@ void processRootDictionary
|
||||||
|
|
||||||
// retrieve file entries
|
// retrieve file entries
|
||||||
extractFileEntries
|
extractFileEntries
|
||||||
(ctx, torrent, infoDict, defaultName, overrideName, urlList);
|
(ctx, torrent, infoDict, option, defaultName, overrideName, urlList);
|
||||||
if((ctx->getTotalLength()+pieceLength-1)/pieceLength != numPieces) {
|
if((ctx->getTotalLength()+pieceLength-1)/pieceLength != numPieces) {
|
||||||
throw DL_ABORT_EX2("Too few/many piece hash.",
|
throw DL_ABORT_EX2("Too few/many piece hash.",
|
||||||
error_code::BITTORRENT_PARSE_ERROR);
|
error_code::BITTORRENT_PARSE_ERROR);
|
||||||
|
@ -500,10 +504,12 @@ void processRootDictionary
|
||||||
|
|
||||||
void load(const std::string& torrentFile,
|
void load(const std::string& torrentFile,
|
||||||
const SharedHandle<DownloadContext>& ctx,
|
const SharedHandle<DownloadContext>& ctx,
|
||||||
|
const SharedHandle<Option>& option,
|
||||||
const std::string& overrideName)
|
const std::string& overrideName)
|
||||||
{
|
{
|
||||||
processRootDictionary(ctx,
|
processRootDictionary(ctx,
|
||||||
bencode2::decodeFromFile(torrentFile),
|
bencode2::decodeFromFile(torrentFile),
|
||||||
|
option,
|
||||||
torrentFile,
|
torrentFile,
|
||||||
overrideName,
|
overrideName,
|
||||||
std::vector<std::string>());
|
std::vector<std::string>());
|
||||||
|
@ -511,11 +517,13 @@ void load(const std::string& torrentFile,
|
||||||
|
|
||||||
void load(const std::string& torrentFile,
|
void load(const std::string& torrentFile,
|
||||||
const SharedHandle<DownloadContext>& ctx,
|
const SharedHandle<DownloadContext>& ctx,
|
||||||
|
const SharedHandle<Option>& option,
|
||||||
const std::vector<std::string>& uris,
|
const std::vector<std::string>& uris,
|
||||||
const std::string& overrideName)
|
const std::string& overrideName)
|
||||||
{
|
{
|
||||||
processRootDictionary(ctx,
|
processRootDictionary(ctx,
|
||||||
bencode2::decodeFromFile(torrentFile),
|
bencode2::decodeFromFile(torrentFile),
|
||||||
|
option,
|
||||||
torrentFile,
|
torrentFile,
|
||||||
overrideName,
|
overrideName,
|
||||||
uris);
|
uris);
|
||||||
|
@ -524,11 +532,13 @@ void load(const std::string& torrentFile,
|
||||||
void loadFromMemory(const unsigned char* content,
|
void loadFromMemory(const unsigned char* content,
|
||||||
size_t length,
|
size_t length,
|
||||||
const SharedHandle<DownloadContext>& ctx,
|
const SharedHandle<DownloadContext>& ctx,
|
||||||
|
const SharedHandle<Option>& option,
|
||||||
const std::string& defaultName,
|
const std::string& defaultName,
|
||||||
const std::string& overrideName)
|
const std::string& overrideName)
|
||||||
{
|
{
|
||||||
processRootDictionary(ctx,
|
processRootDictionary(ctx,
|
||||||
bencode2::decode(content, length),
|
bencode2::decode(content, length),
|
||||||
|
option,
|
||||||
defaultName,
|
defaultName,
|
||||||
overrideName,
|
overrideName,
|
||||||
std::vector<std::string>());
|
std::vector<std::string>());
|
||||||
|
@ -537,12 +547,14 @@ void loadFromMemory(const unsigned char* content,
|
||||||
void loadFromMemory(const unsigned char* content,
|
void loadFromMemory(const unsigned char* content,
|
||||||
size_t length,
|
size_t length,
|
||||||
const SharedHandle<DownloadContext>& ctx,
|
const SharedHandle<DownloadContext>& ctx,
|
||||||
|
const SharedHandle<Option>& option,
|
||||||
const std::vector<std::string>& uris,
|
const std::vector<std::string>& uris,
|
||||||
const std::string& defaultName,
|
const std::string& defaultName,
|
||||||
const std::string& overrideName)
|
const std::string& overrideName)
|
||||||
{
|
{
|
||||||
processRootDictionary(ctx,
|
processRootDictionary(ctx,
|
||||||
bencode2::decode(content, length),
|
bencode2::decode(content, length),
|
||||||
|
option,
|
||||||
defaultName,
|
defaultName,
|
||||||
overrideName,
|
overrideName,
|
||||||
uris);
|
uris);
|
||||||
|
@ -550,18 +562,21 @@ void loadFromMemory(const unsigned char* content,
|
||||||
|
|
||||||
void loadFromMemory(const std::string& context,
|
void loadFromMemory(const std::string& context,
|
||||||
const SharedHandle<DownloadContext>& ctx,
|
const SharedHandle<DownloadContext>& ctx,
|
||||||
|
const SharedHandle<Option>& option,
|
||||||
const std::string& defaultName,
|
const std::string& defaultName,
|
||||||
const std::string& overrideName)
|
const std::string& overrideName)
|
||||||
{
|
{
|
||||||
processRootDictionary
|
processRootDictionary
|
||||||
(ctx,
|
(ctx,
|
||||||
bencode2::decode(context),
|
bencode2::decode(context),
|
||||||
|
option,
|
||||||
defaultName, overrideName,
|
defaultName, overrideName,
|
||||||
std::vector<std::string>());
|
std::vector<std::string>());
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadFromMemory(const std::string& context,
|
void loadFromMemory(const std::string& context,
|
||||||
const SharedHandle<DownloadContext>& ctx,
|
const SharedHandle<DownloadContext>& ctx,
|
||||||
|
const SharedHandle<Option>& option,
|
||||||
const std::vector<std::string>& uris,
|
const std::vector<std::string>& uris,
|
||||||
const std::string& defaultName,
|
const std::string& defaultName,
|
||||||
const std::string& overrideName)
|
const std::string& overrideName)
|
||||||
|
@ -569,6 +584,7 @@ void loadFromMemory(const std::string& context,
|
||||||
processRootDictionary
|
processRootDictionary
|
||||||
(ctx,
|
(ctx,
|
||||||
bencode2::decode(context),
|
bencode2::decode(context),
|
||||||
|
option,
|
||||||
defaultName, overrideName,
|
defaultName, overrideName,
|
||||||
uris);
|
uris);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,31 +66,37 @@ extern const std::string BITTORRENT;
|
||||||
|
|
||||||
void load(const std::string& torrentFile,
|
void load(const std::string& torrentFile,
|
||||||
const SharedHandle<DownloadContext>& ctx,
|
const SharedHandle<DownloadContext>& ctx,
|
||||||
|
const SharedHandle<Option>& option,
|
||||||
const std::string& overrideName = "");
|
const std::string& overrideName = "");
|
||||||
|
|
||||||
void load(const std::string& torrentFile,
|
void load(const std::string& torrentFile,
|
||||||
const SharedHandle<DownloadContext>& ctx,
|
const SharedHandle<DownloadContext>& ctx,
|
||||||
|
const SharedHandle<Option>& option,
|
||||||
const std::vector<std::string>& uris,
|
const std::vector<std::string>& uris,
|
||||||
const std::string& overrideName = "");
|
const std::string& overrideName = "");
|
||||||
|
|
||||||
void loadFromMemory(const unsigned char* content, size_t length,
|
void loadFromMemory(const unsigned char* content, size_t length,
|
||||||
const SharedHandle<DownloadContext>& ctx,
|
const SharedHandle<DownloadContext>& ctx,
|
||||||
|
const SharedHandle<Option>& option,
|
||||||
const std::string& defaultName,
|
const std::string& defaultName,
|
||||||
const std::string& overrideName = "");
|
const std::string& overrideName = "");
|
||||||
|
|
||||||
void loadFromMemory(const unsigned char* content, size_t length,
|
void loadFromMemory(const unsigned char* content, size_t length,
|
||||||
const SharedHandle<DownloadContext>& ctx,
|
const SharedHandle<DownloadContext>& ctx,
|
||||||
|
const SharedHandle<Option>& option,
|
||||||
const std::vector<std::string>& uris,
|
const std::vector<std::string>& uris,
|
||||||
const std::string& defaultName,
|
const std::string& defaultName,
|
||||||
const std::string& overrideName = "");
|
const std::string& overrideName = "");
|
||||||
|
|
||||||
void loadFromMemory(const std::string& context,
|
void loadFromMemory(const std::string& context,
|
||||||
const SharedHandle<DownloadContext>& ctx,
|
const SharedHandle<DownloadContext>& ctx,
|
||||||
|
const SharedHandle<Option>& option,
|
||||||
const std::string& defaultName,
|
const std::string& defaultName,
|
||||||
const std::string& overrideName = "");
|
const std::string& overrideName = "");
|
||||||
|
|
||||||
void loadFromMemory(const std::string& context,
|
void loadFromMemory(const std::string& context,
|
||||||
const SharedHandle<DownloadContext>& ctx,
|
const SharedHandle<DownloadContext>& ctx,
|
||||||
|
const SharedHandle<Option>& option,
|
||||||
const std::vector<std::string>& uris,
|
const std::vector<std::string>& uris,
|
||||||
const std::string& defaultName,
|
const std::string& defaultName,
|
||||||
const std::string& overrideName = "");
|
const std::string& overrideName = "");
|
||||||
|
|
|
@ -222,7 +222,6 @@ SharedHandle<RequestGroup> createRequestGroup
|
||||||
0,
|
0,
|
||||||
useOutOption&&!option->blank(PREF_OUT)?
|
useOutOption&&!option->blank(PREF_OUT)?
|
||||||
util::applyDir(option->get(PREF_DIR), option->get(PREF_OUT)):A2STR::NIL));
|
util::applyDir(option->get(PREF_DIR), option->get(PREF_OUT)):A2STR::NIL));
|
||||||
dctx->setDir(option->get(PREF_DIR));
|
|
||||||
dctx->getFirstFileEntry()->setUris(uris);
|
dctx->getFirstFileEntry()->setUris(uris);
|
||||||
dctx->getFirstFileEntry()->setMaxConnectionPerServer
|
dctx->getFirstFileEntry()->setMaxConnectionPerServer
|
||||||
(option->getAsInt(PREF_MAX_CONNECTION_PER_SERVER));
|
(option->getAsInt(PREF_MAX_CONNECTION_PER_SERVER));
|
||||||
|
@ -259,14 +258,13 @@ createBtRequestGroup(const std::string& torrentFilePath,
|
||||||
{
|
{
|
||||||
SharedHandle<RequestGroup> rg(new RequestGroup(option));
|
SharedHandle<RequestGroup> rg(new RequestGroup(option));
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
dctx->setDir(option->get(PREF_DIR));
|
|
||||||
if(torrentData.empty()) {
|
if(torrentData.empty()) {
|
||||||
bittorrent::load(torrentFilePath, dctx, auxUris);// may throw exception
|
// may throw exception
|
||||||
|
bittorrent::load(torrentFilePath, dctx, option, auxUris);
|
||||||
rg->setMetadataInfo(createMetadataInfo(torrentFilePath));
|
rg->setMetadataInfo(createMetadataInfo(torrentFilePath));
|
||||||
} else {
|
} else {
|
||||||
bittorrent::loadFromMemory(torrentData, dctx, auxUris, "default"); // may
|
// may throw exception
|
||||||
// throw
|
bittorrent::loadFromMemory(torrentData, dctx, option, auxUris, "default");
|
||||||
// exception
|
|
||||||
rg->setMetadataInfo(createMetadataInfoDataOnly());
|
rg->setMetadataInfo(createMetadataInfoDataOnly());
|
||||||
}
|
}
|
||||||
if(adjustAnnounceUri) {
|
if(adjustAnnounceUri) {
|
||||||
|
@ -279,7 +277,7 @@ createBtRequestGroup(const std::string& torrentFilePath,
|
||||||
for(std::map<size_t, std::string>::const_iterator i = indexPathMap.begin(),
|
for(std::map<size_t, std::string>::const_iterator i = indexPathMap.begin(),
|
||||||
eoi = indexPathMap.end(); i != eoi; ++i) {
|
eoi = indexPathMap.end(); i != eoi; ++i) {
|
||||||
dctx->setFilePathWithIndex
|
dctx->setFilePathWithIndex
|
||||||
((*i).first, util::applyDir(dctx->getDir(), (*i).second));
|
((*i).first, util::applyDir(option->get(PREF_DIR), (*i).second));
|
||||||
}
|
}
|
||||||
rg->setDownloadContext(dctx);
|
rg->setDownloadContext(dctx);
|
||||||
// Remove "metalink" from Accept Type list to avoid server from
|
// Remove "metalink" from Accept Type list to avoid server from
|
||||||
|
@ -299,7 +297,6 @@ createBtMagnetRequestGroup(const std::string& magnetLink,
|
||||||
SharedHandle<DownloadContext> dctx
|
SharedHandle<DownloadContext> dctx
|
||||||
(new DownloadContext(METADATA_PIECE_SIZE, 0,
|
(new DownloadContext(METADATA_PIECE_SIZE, 0,
|
||||||
A2STR::NIL));
|
A2STR::NIL));
|
||||||
dctx->setDir(A2STR::NIL);
|
|
||||||
// We only know info hash. Total Length is unknown at this moment.
|
// We only know info hash. Total Length is unknown at this moment.
|
||||||
dctx->markTotalLengthIsUnknown();
|
dctx->markTotalLengthIsUnknown();
|
||||||
rg->setFileAllocationEnabled(false);
|
rg->setFileAllocationEnabled(false);
|
||||||
|
|
|
@ -113,8 +113,9 @@ std::ostream& getSummaryOut(const SharedHandle<Option>& op)
|
||||||
namespace {
|
namespace {
|
||||||
void showTorrentFile(const std::string& uri)
|
void showTorrentFile(const std::string& uri)
|
||||||
{
|
{
|
||||||
|
SharedHandle<Option> op(new Option());
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
bittorrent::load(uri, dctx);
|
bittorrent::load(uri, dctx, op);
|
||||||
bittorrent::print(std::cout, dctx);
|
bittorrent::print(std::cout, dctx);
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -75,7 +75,12 @@ class BittorrentHelperTest:public CppUnit::TestFixture {
|
||||||
CPPUNIT_TEST(testAdjustAnnounceUri);
|
CPPUNIT_TEST(testAdjustAnnounceUri);
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
public:
|
public:
|
||||||
void setUp() {
|
SharedHandle<Option> option_;
|
||||||
|
|
||||||
|
void setUp()
|
||||||
|
{
|
||||||
|
option_.reset(new Option());
|
||||||
|
option_->put(PREF_DIR, ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
void testGetInfoHash();
|
void testGetInfoHash();
|
||||||
|
@ -132,7 +137,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(BittorrentHelperTest);
|
||||||
|
|
||||||
void BittorrentHelperTest::testGetInfoHash() {
|
void BittorrentHelperTest::testGetInfoHash() {
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/test.torrent", dctx);
|
load(A2_TEST_DIR"/test.torrent", dctx, option_);
|
||||||
|
|
||||||
std::string correctHash = "248d0a1cd08284299de78d5c1ed359bb46717d8c";
|
std::string correctHash = "248d0a1cd08284299de78d5c1ed359bb46717d8c";
|
||||||
|
|
||||||
|
@ -141,7 +146,7 @@ void BittorrentHelperTest::testGetInfoHash() {
|
||||||
|
|
||||||
void BittorrentHelperTest::testGetPieceHash() {
|
void BittorrentHelperTest::testGetPieceHash() {
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/test.torrent", dctx);
|
load(A2_TEST_DIR"/test.torrent", dctx, option_);
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(util::toHex("AAAAAAAAAAAAAAAAAAAA", 20),
|
CPPUNIT_ASSERT_EQUAL(util::toHex("AAAAAAAAAAAAAAAAAAAA", 20),
|
||||||
dctx->getPieceHash(0));
|
dctx->getPieceHash(0));
|
||||||
|
@ -157,7 +162,7 @@ void BittorrentHelperTest::testGetPieceHash() {
|
||||||
|
|
||||||
void BittorrentHelperTest::testGetFileEntries() {
|
void BittorrentHelperTest::testGetFileEntries() {
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/test.torrent", dctx);
|
load(A2_TEST_DIR"/test.torrent", dctx, option_);
|
||||||
// This is multi-file torrent.
|
// This is multi-file torrent.
|
||||||
std::vector<SharedHandle<FileEntry> > fileEntries = dctx->getFileEntries();
|
std::vector<SharedHandle<FileEntry> > fileEntries = dctx->getFileEntries();
|
||||||
// There are 2 file entries.
|
// There are 2 file entries.
|
||||||
|
@ -177,7 +182,7 @@ void BittorrentHelperTest::testGetFileEntries() {
|
||||||
|
|
||||||
void BittorrentHelperTest::testGetFileEntriesSingle() {
|
void BittorrentHelperTest::testGetFileEntriesSingle() {
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/single.torrent", dctx);
|
load(A2_TEST_DIR"/single.torrent", dctx, option_);
|
||||||
// This is multi-file torrent.
|
// This is multi-file torrent.
|
||||||
std::vector<SharedHandle<FileEntry> > fileEntries = dctx->getFileEntries();
|
std::vector<SharedHandle<FileEntry> > fileEntries = dctx->getFileEntries();
|
||||||
// There is 1 file entry.
|
// There is 1 file entry.
|
||||||
|
@ -193,42 +198,42 @@ void BittorrentHelperTest::testGetFileEntriesSingle() {
|
||||||
|
|
||||||
void BittorrentHelperTest::testGetTotalLength() {
|
void BittorrentHelperTest::testGetTotalLength() {
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/test.torrent", dctx);
|
load(A2_TEST_DIR"/test.torrent", dctx, option_);
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL((uint64_t)384ULL, dctx->getTotalLength());
|
CPPUNIT_ASSERT_EQUAL((uint64_t)384ULL, dctx->getTotalLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BittorrentHelperTest::testGetTotalLengthSingle() {
|
void BittorrentHelperTest::testGetTotalLengthSingle() {
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/single.torrent", dctx);
|
load(A2_TEST_DIR"/single.torrent", dctx, option_);
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL((uint64_t)384ULL, dctx->getTotalLength());
|
CPPUNIT_ASSERT_EQUAL((uint64_t)384ULL, dctx->getTotalLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BittorrentHelperTest::testGetFileModeMulti() {
|
void BittorrentHelperTest::testGetFileModeMulti() {
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/test.torrent", dctx);
|
load(A2_TEST_DIR"/test.torrent", dctx, option_);
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(MULTI, getTorrentAttrs(dctx)->mode);
|
CPPUNIT_ASSERT_EQUAL(MULTI, getTorrentAttrs(dctx)->mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BittorrentHelperTest::testGetFileModeSingle() {
|
void BittorrentHelperTest::testGetFileModeSingle() {
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/single.torrent", dctx);
|
load(A2_TEST_DIR"/single.torrent", dctx, option_);
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(SINGLE, getTorrentAttrs(dctx)->mode);
|
CPPUNIT_ASSERT_EQUAL(SINGLE, getTorrentAttrs(dctx)->mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BittorrentHelperTest::testGetNameMulti() {
|
void BittorrentHelperTest::testGetNameMulti() {
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/test.torrent", dctx);
|
load(A2_TEST_DIR"/test.torrent", dctx, option_);
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2-test"), getTorrentAttrs(dctx)->name);
|
CPPUNIT_ASSERT_EQUAL(std::string("aria2-test"), getTorrentAttrs(dctx)->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BittorrentHelperTest::testGetNameSingle() {
|
void BittorrentHelperTest::testGetNameSingle() {
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/single.torrent", dctx);
|
load(A2_TEST_DIR"/single.torrent", dctx, option_);
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("./aria2-0.8.2.tar.bz2"),
|
CPPUNIT_ASSERT_EQUAL(std::string("./aria2-0.8.2.tar.bz2"),
|
||||||
dctx->getBasePath());
|
dctx->getBasePath());
|
||||||
|
@ -239,7 +244,7 @@ void BittorrentHelperTest::testGetNameSingle() {
|
||||||
void BittorrentHelperTest::testOverrideName()
|
void BittorrentHelperTest::testOverrideName()
|
||||||
{
|
{
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/test.torrent", dctx, "aria2-override.name");
|
load(A2_TEST_DIR"/test.torrent", dctx, option_, "aria2-override.name");
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("./aria2-override.name"),
|
CPPUNIT_ASSERT_EQUAL(std::string("./aria2-override.name"),
|
||||||
dctx->getBasePath());
|
dctx->getBasePath());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2-override.name"),
|
CPPUNIT_ASSERT_EQUAL(std::string("aria2-override.name"),
|
||||||
|
@ -249,7 +254,7 @@ void BittorrentHelperTest::testOverrideName()
|
||||||
|
|
||||||
void BittorrentHelperTest::testGetAnnounceTier() {
|
void BittorrentHelperTest::testGetAnnounceTier() {
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/single.torrent", dctx);
|
load(A2_TEST_DIR"/single.torrent", dctx, option_);
|
||||||
SharedHandle<TorrentAttribute> attrs = getTorrentAttrs(dctx);
|
SharedHandle<TorrentAttribute> attrs = getTorrentAttrs(dctx);
|
||||||
// There is 1 tier.
|
// There is 1 tier.
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)1, attrs->announceList.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)1, attrs->announceList.size());
|
||||||
|
@ -261,7 +266,7 @@ void BittorrentHelperTest::testGetAnnounceTier() {
|
||||||
|
|
||||||
void BittorrentHelperTest::testGetAnnounceTierAnnounceList() {
|
void BittorrentHelperTest::testGetAnnounceTierAnnounceList() {
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/test.torrent", dctx);
|
load(A2_TEST_DIR"/test.torrent", dctx, option_);
|
||||||
SharedHandle<TorrentAttribute> attrs = getTorrentAttrs(dctx);
|
SharedHandle<TorrentAttribute> attrs = getTorrentAttrs(dctx);
|
||||||
// There are 3 tiers.
|
// There are 3 tiers.
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)3, attrs->announceList.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)3, attrs->announceList.size());
|
||||||
|
@ -281,14 +286,14 @@ void BittorrentHelperTest::testGetAnnounceTierAnnounceList() {
|
||||||
|
|
||||||
void BittorrentHelperTest::testGetPieceLength() {
|
void BittorrentHelperTest::testGetPieceLength() {
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/test.torrent", dctx);
|
load(A2_TEST_DIR"/test.torrent", dctx, option_);
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)128, dctx->getPieceLength());
|
CPPUNIT_ASSERT_EQUAL((size_t)128, dctx->getPieceLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BittorrentHelperTest::testGetInfoHashAsString() {
|
void BittorrentHelperTest::testGetInfoHashAsString() {
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/test.torrent", dctx);
|
load(A2_TEST_DIR"/test.torrent", dctx, option_);
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("248d0a1cd08284299de78d5c1ed359bb46717d8c"),
|
CPPUNIT_ASSERT_EQUAL(std::string("248d0a1cd08284299de78d5c1ed359bb46717d8c"),
|
||||||
getInfoHashString(dctx));
|
getInfoHashString(dctx));
|
||||||
|
@ -336,7 +341,7 @@ void BittorrentHelperTest::testComputeFastSet()
|
||||||
|
|
||||||
void BittorrentHelperTest::testGetFileEntries_multiFileUrlList() {
|
void BittorrentHelperTest::testGetFileEntries_multiFileUrlList() {
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/url-list-multiFile.torrent", dctx);
|
load(A2_TEST_DIR"/url-list-multiFile.torrent", dctx, option_);
|
||||||
// This is multi-file torrent.
|
// This is multi-file torrent.
|
||||||
const std::vector<SharedHandle<FileEntry> >& fileEntries =
|
const std::vector<SharedHandle<FileEntry> >& fileEntries =
|
||||||
dctx->getFileEntries();
|
dctx->getFileEntries();
|
||||||
|
@ -369,7 +374,7 @@ void BittorrentHelperTest::testGetFileEntries_multiFileUrlList() {
|
||||||
|
|
||||||
void BittorrentHelperTest::testGetFileEntries_singleFileUrlList() {
|
void BittorrentHelperTest::testGetFileEntries_singleFileUrlList() {
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/url-list-singleFile.torrent", dctx);
|
load(A2_TEST_DIR"/url-list-singleFile.torrent", dctx, option_);
|
||||||
// This is single-file torrent.
|
// This is single-file torrent.
|
||||||
const std::vector<SharedHandle<FileEntry> >& fileEntries =
|
const std::vector<SharedHandle<FileEntry> >& fileEntries =
|
||||||
dctx->getFileEntries();
|
dctx->getFileEntries();
|
||||||
|
@ -387,7 +392,7 @@ void BittorrentHelperTest::testGetFileEntries_singleFileUrlList() {
|
||||||
|
|
||||||
void BittorrentHelperTest::testGetFileEntries_singleFileUrlListEndsWithSlash() {
|
void BittorrentHelperTest::testGetFileEntries_singleFileUrlListEndsWithSlash() {
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/url-list-singleFileEndsWithSlash.torrent", dctx);
|
load(A2_TEST_DIR"/url-list-singleFileEndsWithSlash.torrent", dctx, option_);
|
||||||
// This is single-file torrent.
|
// This is single-file torrent.
|
||||||
const std::vector<SharedHandle<FileEntry> >& fileEntries =
|
const std::vector<SharedHandle<FileEntry> >& fileEntries =
|
||||||
dctx->getFileEntries();
|
dctx->getFileEntries();
|
||||||
|
@ -421,7 +426,7 @@ void BittorrentHelperTest::testLoadFromMemory_multiFileNonUtf8Path()
|
||||||
Dict dict;
|
Dict dict;
|
||||||
dict.put("info", info);
|
dict.put("info", info);
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
loadFromMemory(bencode2::encode(&dict), dctx, "default");
|
loadFromMemory(bencode2::encode(&dict), dctx, option_, "default");
|
||||||
|
|
||||||
const SharedHandle<FileEntry>& fe = dctx->getFirstFileEntry();
|
const SharedHandle<FileEntry>& fe = dctx->getFirstFileEntry();
|
||||||
CPPUNIT_ASSERT_EQUAL
|
CPPUNIT_ASSERT_EQUAL
|
||||||
|
@ -441,7 +446,7 @@ void BittorrentHelperTest::testLoadFromMemory_singleFileNonUtf8Path()
|
||||||
Dict dict;
|
Dict dict;
|
||||||
dict.put("info", info);
|
dict.put("info", info);
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
loadFromMemory(bencode2::encode(&dict), dctx, "default");
|
loadFromMemory(bencode2::encode(&dict), dctx, option_, "default");
|
||||||
|
|
||||||
const SharedHandle<FileEntry>& fe = dctx->getFirstFileEntry();
|
const SharedHandle<FileEntry>& fe = dctx->getFirstFileEntry();
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("./%90%A2%8AE"), fe->getPath());
|
CPPUNIT_ASSERT_EQUAL(std::string("./%90%A2%8AE"), fe->getPath());
|
||||||
|
@ -452,7 +457,7 @@ void BittorrentHelperTest::testLoadFromMemory()
|
||||||
std::string memory = "d8:announce36:http://aria.rednoah.com/announce.php13:announce-listll16:http://tracker1 el15:http://tracker2el15:http://tracker3ee7:comment17:REDNOAH.COM RULES13:creation datei1123456789e4:infod5:filesld6:lengthi284e4:pathl5:aria23:src6:aria2ceed6:lengthi100e4:pathl19:aria2-0.2.2.tar.bz2eee4:name10:aria2-test12:piece lengthi128e6:pieces60:AAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCee";
|
std::string memory = "d8:announce36:http://aria.rednoah.com/announce.php13:announce-listll16:http://tracker1 el15:http://tracker2el15:http://tracker3ee7:comment17:REDNOAH.COM RULES13:creation datei1123456789e4:infod5:filesld6:lengthi284e4:pathl5:aria23:src6:aria2ceed6:lengthi100e4:pathl19:aria2-0.2.2.tar.bz2eee4:name10:aria2-test12:piece lengthi128e6:pieces60:AAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCee";
|
||||||
|
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
loadFromMemory(memory, dctx, "default");
|
loadFromMemory(memory, dctx, option_, "default");
|
||||||
|
|
||||||
std::string correctHash = "248d0a1cd08284299de78d5c1ed359bb46717d8c";
|
std::string correctHash = "248d0a1cd08284299de78d5c1ed359bb46717d8c";
|
||||||
|
|
||||||
|
@ -465,7 +470,7 @@ void BittorrentHelperTest::testLoadFromMemory_somethingMissing()
|
||||||
try {
|
try {
|
||||||
std::string memory = "d8:announce36:http://aria.rednoah.com/announce.php4:infod4:name13:aria2.tar.bz26:lengthi262144eee";
|
std::string memory = "d8:announce36:http://aria.rednoah.com/announce.php4:infod4:name13:aria2.tar.bz26:lengthi262144eee";
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
loadFromMemory(memory, dctx, "default");
|
loadFromMemory(memory, dctx, option_, "default");
|
||||||
CPPUNIT_FAIL("exception must be thrown.");
|
CPPUNIT_FAIL("exception must be thrown.");
|
||||||
} catch(Exception& e) {
|
} catch(Exception& e) {
|
||||||
// OK
|
// OK
|
||||||
|
@ -477,7 +482,7 @@ void BittorrentHelperTest::testLoadFromMemory_overrideName()
|
||||||
std::string memory = "d8:announce36:http://aria.rednoah.com/announce.php13:announce-listll16:http://tracker1 el15:http://tracker2el15:http://tracker3ee7:comment17:REDNOAH.COM RULES13:creation datei1123456789e4:infod5:filesld6:lengthi284e4:pathl5:aria23:src6:aria2ceed6:lengthi100e4:pathl19:aria2-0.2.2.tar.bz2eee4:name10:aria2-test12:piece lengthi128e6:pieces60:AAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCee";
|
std::string memory = "d8:announce36:http://aria.rednoah.com/announce.php13:announce-listll16:http://tracker1 el15:http://tracker2el15:http://tracker3ee7:comment17:REDNOAH.COM RULES13:creation datei1123456789e4:infod5:filesld6:lengthi284e4:pathl5:aria23:src6:aria2ceed6:lengthi100e4:pathl19:aria2-0.2.2.tar.bz2eee4:name10:aria2-test12:piece lengthi128e6:pieces60:AAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCee";
|
||||||
|
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
loadFromMemory(memory, dctx, "default", "aria2-override.name");
|
loadFromMemory(memory, dctx, option_, "default", "aria2-override.name");
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2-override.name"),
|
CPPUNIT_ASSERT_EQUAL(std::string("aria2-override.name"),
|
||||||
getTorrentAttrs(dctx)->name);
|
getTorrentAttrs(dctx)->name);
|
||||||
|
@ -489,9 +494,8 @@ void BittorrentHelperTest::testLoadFromMemory_multiFileDirTraversal()
|
||||||
"d8:announce27:http://example.com/announce4:infod5:filesld6:lengthi262144e4:pathl7:../dir14:dir28:file.imgeee4:name14:../name1/name212:piece lengthi262144e6:pieces20:00000000000000000000ee";
|
"d8:announce27:http://example.com/announce4:infod5:filesld6:lengthi262144e4:pathl7:../dir14:dir28:file.imgeee4:name14:../name1/name212:piece lengthi262144e6:pieces20:00000000000000000000ee";
|
||||||
|
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
dctx->setDir("/tmp");
|
|
||||||
try {
|
try {
|
||||||
loadFromMemory(memory, dctx, "default");
|
loadFromMemory(memory, dctx, option_, "default");
|
||||||
CPPUNIT_FAIL("Exception must be thrown.");
|
CPPUNIT_FAIL("Exception must be thrown.");
|
||||||
} catch(RecoverableException& e) {
|
} catch(RecoverableException& e) {
|
||||||
// success
|
// success
|
||||||
|
@ -504,9 +508,8 @@ void BittorrentHelperTest::testLoadFromMemory_singleFileDirTraversal()
|
||||||
"d8:announce27:http://example.com/announce4:infod4:name14:../name1/name26:lengthi262144e12:piece lengthi262144e6:pieces20:00000000000000000000ee";
|
"d8:announce27:http://example.com/announce4:infod4:name14:../name1/name26:lengthi262144e12:piece lengthi262144e6:pieces20:00000000000000000000ee";
|
||||||
|
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
dctx->setDir("/tmp");
|
|
||||||
try {
|
try {
|
||||||
loadFromMemory(memory, dctx, "default");
|
loadFromMemory(memory, dctx, option_, "default");
|
||||||
} catch(RecoverableException& e) {
|
} catch(RecoverableException& e) {
|
||||||
// success
|
// success
|
||||||
}
|
}
|
||||||
|
@ -524,7 +527,7 @@ void BittorrentHelperTest::testGetNodes()
|
||||||
"6:pieces20:AAAAAAAAAAAAAAAAAAAA"
|
"6:pieces20:AAAAAAAAAAAAAAAAAAAA"
|
||||||
"ee";
|
"ee";
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
loadFromMemory(memory, dctx, "default");
|
loadFromMemory(memory, dctx, option_, "default");
|
||||||
|
|
||||||
SharedHandle<TorrentAttribute> attrs = getTorrentAttrs(dctx);
|
SharedHandle<TorrentAttribute> attrs = getTorrentAttrs(dctx);
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, attrs->nodes.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, attrs->nodes.size());
|
||||||
|
@ -544,7 +547,7 @@ void BittorrentHelperTest::testGetNodes()
|
||||||
"6:pieces20:AAAAAAAAAAAAAAAAAAAA"
|
"6:pieces20:AAAAAAAAAAAAAAAAAAAA"
|
||||||
"ee";
|
"ee";
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
loadFromMemory(memory, dctx, "default");
|
loadFromMemory(memory, dctx, option_, "default");
|
||||||
|
|
||||||
SharedHandle<TorrentAttribute> attrs = getTorrentAttrs(dctx);
|
SharedHandle<TorrentAttribute> attrs = getTorrentAttrs(dctx);
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)1, attrs->nodes.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)1, attrs->nodes.size());
|
||||||
|
@ -562,7 +565,7 @@ void BittorrentHelperTest::testGetNodes()
|
||||||
"6:pieces20:AAAAAAAAAAAAAAAAAAAA"
|
"6:pieces20:AAAAAAAAAAAAAAAAAAAA"
|
||||||
"ee";
|
"ee";
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
loadFromMemory(memory, dctx, "default");
|
loadFromMemory(memory, dctx, option_, "default");
|
||||||
|
|
||||||
SharedHandle<TorrentAttribute> attrs = getTorrentAttrs(dctx);
|
SharedHandle<TorrentAttribute> attrs = getTorrentAttrs(dctx);
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)1, attrs->nodes.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)1, attrs->nodes.size());
|
||||||
|
@ -580,7 +583,7 @@ void BittorrentHelperTest::testGetNodes()
|
||||||
"6:pieces20:AAAAAAAAAAAAAAAAAAAA"
|
"6:pieces20:AAAAAAAAAAAAAAAAAAAA"
|
||||||
"ee";
|
"ee";
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
loadFromMemory(memory, dctx, "default");
|
loadFromMemory(memory, dctx, option_, "default");
|
||||||
|
|
||||||
SharedHandle<TorrentAttribute> attrs = getTorrentAttrs(dctx);
|
SharedHandle<TorrentAttribute> attrs = getTorrentAttrs(dctx);
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)1, attrs->nodes.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)1, attrs->nodes.size());
|
||||||
|
@ -597,7 +600,7 @@ void BittorrentHelperTest::testGetNodes()
|
||||||
"6:pieces20:AAAAAAAAAAAAAAAAAAAA"
|
"6:pieces20:AAAAAAAAAAAAAAAAAAAA"
|
||||||
"ee";
|
"ee";
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
loadFromMemory(memory, dctx, "default");
|
loadFromMemory(memory, dctx, option_, "default");
|
||||||
|
|
||||||
SharedHandle<TorrentAttribute> attrs = getTorrentAttrs(dctx);
|
SharedHandle<TorrentAttribute> attrs = getTorrentAttrs(dctx);
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)0, attrs->nodes.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)0, attrs->nodes.size());
|
||||||
|
@ -613,7 +616,7 @@ void BittorrentHelperTest::testGetNodes()
|
||||||
"6:pieces20:AAAAAAAAAAAAAAAAAAAA"
|
"6:pieces20:AAAAAAAAAAAAAAAAAAAA"
|
||||||
"ee";
|
"ee";
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
loadFromMemory(memory, dctx, "default");
|
loadFromMemory(memory, dctx, option_, "default");
|
||||||
|
|
||||||
SharedHandle<TorrentAttribute> attrs = getTorrentAttrs(dctx);
|
SharedHandle<TorrentAttribute> attrs = getTorrentAttrs(dctx);
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)1, attrs->nodes.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)1, attrs->nodes.size());
|
||||||
|
@ -625,13 +628,13 @@ void BittorrentHelperTest::testGetNodes()
|
||||||
void BittorrentHelperTest::testGetBasePath()
|
void BittorrentHelperTest::testGetBasePath()
|
||||||
{
|
{
|
||||||
SharedHandle<DownloadContext> singleCtx(new DownloadContext());
|
SharedHandle<DownloadContext> singleCtx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/single.torrent", singleCtx);
|
load(A2_TEST_DIR"/single.torrent", singleCtx, option_);
|
||||||
singleCtx->setFilePathWithIndex(1, "new-path");
|
singleCtx->setFilePathWithIndex(1, "new-path");
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("new-path"), singleCtx->getBasePath());
|
CPPUNIT_ASSERT_EQUAL(std::string("new-path"), singleCtx->getBasePath());
|
||||||
|
|
||||||
|
option_->put(PREF_DIR, "downloads");
|
||||||
SharedHandle<DownloadContext> multiCtx(new DownloadContext());
|
SharedHandle<DownloadContext> multiCtx(new DownloadContext());
|
||||||
multiCtx->setDir("downloads");
|
load(A2_TEST_DIR"/test.torrent", multiCtx, option_);
|
||||||
load(A2_TEST_DIR"/test.torrent", multiCtx);
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("downloads/aria2-test"),
|
CPPUNIT_ASSERT_EQUAL(std::string("downloads/aria2-test"),
|
||||||
multiCtx->getBasePath());
|
multiCtx->getBasePath());
|
||||||
}
|
}
|
||||||
|
@ -639,7 +642,7 @@ void BittorrentHelperTest::testGetBasePath()
|
||||||
void BittorrentHelperTest::testSetFileFilter_single()
|
void BittorrentHelperTest::testSetFileFilter_single()
|
||||||
{
|
{
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/single.torrent", dctx);
|
load(A2_TEST_DIR"/single.torrent", dctx, option_);
|
||||||
|
|
||||||
CPPUNIT_ASSERT(dctx->getFirstFileEntry()->isRequested());
|
CPPUNIT_ASSERT(dctx->getFirstFileEntry()->isRequested());
|
||||||
|
|
||||||
|
@ -658,7 +661,7 @@ void BittorrentHelperTest::testSetFileFilter_single()
|
||||||
void BittorrentHelperTest::testSetFileFilter_multi()
|
void BittorrentHelperTest::testSetFileFilter_multi()
|
||||||
{
|
{
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/test.torrent", dctx);
|
load(A2_TEST_DIR"/test.torrent", dctx, option_);
|
||||||
|
|
||||||
CPPUNIT_ASSERT(dctx->getFileEntries()[0]->isRequested());
|
CPPUNIT_ASSERT(dctx->getFileEntries()[0]->isRequested());
|
||||||
CPPUNIT_ASSERT(dctx->getFileEntries()[1]->isRequested());
|
CPPUNIT_ASSERT(dctx->getFileEntries()[1]->isRequested());
|
||||||
|
@ -683,7 +686,7 @@ void BittorrentHelperTest::testSetFileFilter_multi()
|
||||||
void BittorrentHelperTest::testUTF8Torrent()
|
void BittorrentHelperTest::testUTF8Torrent()
|
||||||
{
|
{
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/utf8.torrent", dctx);
|
load(A2_TEST_DIR"/utf8.torrent", dctx, option_);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("name in utf-8"),
|
CPPUNIT_ASSERT_EQUAL(std::string("name in utf-8"),
|
||||||
getTorrentAttrs(dctx)->name);
|
getTorrentAttrs(dctx)->name);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("./name in utf-8/path in utf-8"),
|
CPPUNIT_ASSERT_EQUAL(std::string("./name in utf-8/path in utf-8"),
|
||||||
|
@ -695,7 +698,7 @@ void BittorrentHelperTest::testUTF8Torrent()
|
||||||
void BittorrentHelperTest::testEtc()
|
void BittorrentHelperTest::testEtc()
|
||||||
{
|
{
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/test.torrent", dctx);
|
load(A2_TEST_DIR"/test.torrent", dctx, option_);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("REDNOAH.COM RULES"),
|
CPPUNIT_ASSERT_EQUAL(std::string("REDNOAH.COM RULES"),
|
||||||
getTorrentAttrs(dctx)->comment);
|
getTorrentAttrs(dctx)->comment);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2"),
|
CPPUNIT_ASSERT_EQUAL(std::string("aria2"),
|
||||||
|
@ -726,7 +729,7 @@ void BittorrentHelperTest::testCheckBitfield()
|
||||||
|
|
||||||
void BittorrentHelperTest::testMetadata() {
|
void BittorrentHelperTest::testMetadata() {
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/test.torrent", dctx);
|
load(A2_TEST_DIR"/test.torrent", dctx, option_);
|
||||||
std::string torrentData = readFile(A2_TEST_DIR"/test.torrent");
|
std::string torrentData = readFile(A2_TEST_DIR"/test.torrent");
|
||||||
SharedHandle<ValueBase> tr = bencode2::decode(torrentData);
|
SharedHandle<ValueBase> tr = bencode2::decode(torrentData);
|
||||||
SharedHandle<ValueBase> infoDic = asDict(tr)->get("info");
|
SharedHandle<ValueBase> infoDic = asDict(tr)->get("info");
|
||||||
|
@ -796,7 +799,7 @@ void BittorrentHelperTest::testMetadata2Torrent()
|
||||||
void BittorrentHelperTest::testTorrent2Magnet()
|
void BittorrentHelperTest::testTorrent2Magnet()
|
||||||
{
|
{
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
load(A2_TEST_DIR"/test.torrent", dctx);
|
load(A2_TEST_DIR"/test.torrent", dctx, option_);
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL
|
CPPUNIT_ASSERT_EQUAL
|
||||||
(std::string("magnet:?xt=urn:btih:248D0A1CD08284299DE78D5C1ED359BB46717D8C"
|
(std::string("magnet:?xt=urn:btih:248D0A1CD08284299DE78D5C1ED359BB46717D8C"
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "DirectDiskAdaptor.h"
|
#include "DirectDiskAdaptor.h"
|
||||||
#include "ByteArrayDiskWriter.h"
|
#include "ByteArrayDiskWriter.h"
|
||||||
#include "MockPieceStorage.h"
|
#include "MockPieceStorage.h"
|
||||||
|
#include "prefs.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -38,7 +39,6 @@ class BtDependencyTest:public CppUnit::TestFixture {
|
||||||
SharedHandle<RequestGroup> dependant(new RequestGroup(option));
|
SharedHandle<RequestGroup> dependant(new RequestGroup(option));
|
||||||
SharedHandle<DownloadContext> dctx
|
SharedHandle<DownloadContext> dctx
|
||||||
(new DownloadContext(0, 0, "/tmp/outfile.path"));
|
(new DownloadContext(0, 0, "/tmp/outfile.path"));
|
||||||
dctx->setDir("/tmp");
|
|
||||||
std::vector<std::string> uris;
|
std::vector<std::string> uris;
|
||||||
uris.push_back("http://localhost/outfile.path");
|
uris.push_back("http://localhost/outfile.path");
|
||||||
SharedHandle<FileEntry> fileEntry = dctx->getFirstFileEntry();
|
SharedHandle<FileEntry> fileEntry = dctx->getFirstFileEntry();
|
||||||
|
@ -57,7 +57,6 @@ class BtDependencyTest:public CppUnit::TestFixture {
|
||||||
SharedHandle<RequestGroup> dependee(new RequestGroup(option));
|
SharedHandle<RequestGroup> dependee(new RequestGroup(option));
|
||||||
SharedHandle<DownloadContext> dctx
|
SharedHandle<DownloadContext> dctx
|
||||||
(new DownloadContext(1024*1024, length, torrentFile));
|
(new DownloadContext(1024*1024, length, torrentFile));
|
||||||
dctx->setDir(".");
|
|
||||||
dependee->setDownloadContext(dctx);
|
dependee->setDownloadContext(dctx);
|
||||||
dependee->initPieceStorage();
|
dependee->initPieceStorage();
|
||||||
return dependee;
|
return dependee;
|
||||||
|
@ -68,6 +67,7 @@ public:
|
||||||
void setUp()
|
void setUp()
|
||||||
{
|
{
|
||||||
option_.reset(new Option());
|
option_.reset(new Option());
|
||||||
|
option_->put(PREF_DIR, "/tmp");
|
||||||
}
|
}
|
||||||
|
|
||||||
void testResolve();
|
void testResolve();
|
||||||
|
|
|
@ -136,11 +136,12 @@ public:
|
||||||
|
|
||||||
void setUp() {
|
void setUp() {
|
||||||
option_.reset(new Option());
|
option_.reset(new Option());
|
||||||
|
option_->put(PREF_DIR, ".");
|
||||||
|
|
||||||
rg_.reset(new RequestGroup(option_));
|
rg_.reset(new RequestGroup(option_));
|
||||||
|
|
||||||
dctx_.reset(new DownloadContext());
|
dctx_.reset(new DownloadContext());
|
||||||
bittorrent::load(A2_TEST_DIR"/test.torrent", dctx_);
|
bittorrent::load(A2_TEST_DIR"/test.torrent", dctx_, option_);
|
||||||
|
|
||||||
rg_->setDownloadContext(dctx_);
|
rg_->setDownloadContext(dctx_);
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,6 @@ public:
|
||||||
SharedHandle<TorrentAttribute> torrentAttrs(new TorrentAttribute());
|
SharedHandle<TorrentAttribute> torrentAttrs(new TorrentAttribute());
|
||||||
torrentAttrs->infoHash = std::string(vbegin(infoHash), vend(infoHash));
|
torrentAttrs->infoHash = std::string(vbegin(infoHash), vend(infoHash));
|
||||||
dctx_->setAttribute(bittorrent::BITTORRENT, torrentAttrs);
|
dctx_->setAttribute(bittorrent::BITTORRENT, torrentAttrs);
|
||||||
dctx_->setDir(option_->get(PREF_DIR));
|
|
||||||
const SharedHandle<FileEntry> fileEntries[] = {
|
const SharedHandle<FileEntry> fileEntries[] = {
|
||||||
SharedHandle<FileEntry>(new FileEntry("/path/to/file",totalLength,0))
|
SharedHandle<FileEntry>(new FileEntry("/path/to/file",totalLength,0))
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "DiskAdaptor.h"
|
#include "DiskAdaptor.h"
|
||||||
#include "DiskWriterFactory.h"
|
#include "DiskWriterFactory.h"
|
||||||
#include "PieceStatMan.h"
|
#include "PieceStatMan.h"
|
||||||
|
#include "prefs.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -41,25 +42,20 @@ class DefaultPieceStorageTest:public CppUnit::TestFixture {
|
||||||
private:
|
private:
|
||||||
SharedHandle<DownloadContext> dctx_;
|
SharedHandle<DownloadContext> dctx_;
|
||||||
SharedHandle<Peer> peer;
|
SharedHandle<Peer> peer;
|
||||||
Option* option;
|
SharedHandle<Option> option_;
|
||||||
SharedHandle<PieceSelector> pieceSelector_;
|
SharedHandle<PieceSelector> pieceSelector_;
|
||||||
public:
|
public:
|
||||||
void setUp() {
|
void setUp() {
|
||||||
|
option_.reset(new Option());
|
||||||
|
option_->put(PREF_DIR, ".");
|
||||||
dctx_.reset(new DownloadContext());
|
dctx_.reset(new DownloadContext());
|
||||||
bittorrent::load(A2_TEST_DIR"/test.torrent", dctx_);
|
bittorrent::load(A2_TEST_DIR"/test.torrent", dctx_, option_);
|
||||||
peer.reset(new Peer("192.168.0.1", 6889));
|
peer.reset(new Peer("192.168.0.1", 6889));
|
||||||
peer->allocateSessionResource(dctx_->getPieceLength(),
|
peer->allocateSessionResource(dctx_->getPieceLength(),
|
||||||
dctx_->getTotalLength());
|
dctx_->getTotalLength());
|
||||||
option = new Option();
|
|
||||||
pieceSelector_.reset(new InOrderPieceSelector());
|
pieceSelector_.reset(new InOrderPieceSelector());
|
||||||
}
|
}
|
||||||
|
|
||||||
void tearDown()
|
|
||||||
{
|
|
||||||
delete option;
|
|
||||||
option = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void testGetTotalLength();
|
void testGetTotalLength();
|
||||||
void testGetMissingPiece();
|
void testGetMissingPiece();
|
||||||
void testGetMissingPiece_many();
|
void testGetMissingPiece_many();
|
||||||
|
@ -82,13 +78,13 @@ public:
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION(DefaultPieceStorageTest);
|
CPPUNIT_TEST_SUITE_REGISTRATION(DefaultPieceStorageTest);
|
||||||
|
|
||||||
void DefaultPieceStorageTest::testGetTotalLength() {
|
void DefaultPieceStorageTest::testGetTotalLength() {
|
||||||
DefaultPieceStorage pss(dctx_, option);
|
DefaultPieceStorage pss(dctx_, option_.get());
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL((uint64_t)384ULL, pss.getTotalLength());
|
CPPUNIT_ASSERT_EQUAL((uint64_t)384ULL, pss.getTotalLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultPieceStorageTest::testGetMissingPiece() {
|
void DefaultPieceStorageTest::testGetMissingPiece() {
|
||||||
DefaultPieceStorage pss(dctx_, option);
|
DefaultPieceStorage pss(dctx_, option_.get());
|
||||||
pss.setPieceSelector(pieceSelector_);
|
pss.setPieceSelector(pieceSelector_);
|
||||||
peer->setAllBitfield();
|
peer->setAllBitfield();
|
||||||
|
|
||||||
|
@ -106,7 +102,7 @@ void DefaultPieceStorageTest::testGetMissingPiece() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultPieceStorageTest::testGetMissingPiece_many() {
|
void DefaultPieceStorageTest::testGetMissingPiece_many() {
|
||||||
DefaultPieceStorage pss(dctx_, option);
|
DefaultPieceStorage pss(dctx_, option_.get());
|
||||||
pss.setPieceSelector(pieceSelector_);
|
pss.setPieceSelector(pieceSelector_);
|
||||||
peer->setAllBitfield();
|
peer->setAllBitfield();
|
||||||
std::vector<SharedHandle<Piece> > pieces;
|
std::vector<SharedHandle<Piece> > pieces;
|
||||||
|
@ -125,7 +121,7 @@ void DefaultPieceStorageTest::testGetMissingPiece_many() {
|
||||||
|
|
||||||
void DefaultPieceStorageTest::testGetMissingPiece_excludedIndexes()
|
void DefaultPieceStorageTest::testGetMissingPiece_excludedIndexes()
|
||||||
{
|
{
|
||||||
DefaultPieceStorage pss(dctx_, option);
|
DefaultPieceStorage pss(dctx_, option_.get());
|
||||||
pss.setPieceSelector(pieceSelector_);
|
pss.setPieceSelector(pieceSelector_);
|
||||||
pss.setEndGamePieceNum(0);
|
pss.setEndGamePieceNum(0);
|
||||||
|
|
||||||
|
@ -147,7 +143,7 @@ void DefaultPieceStorageTest::testGetMissingPiece_excludedIndexes()
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultPieceStorageTest::testGetMissingPiece_manyWithExcludedIndexes() {
|
void DefaultPieceStorageTest::testGetMissingPiece_manyWithExcludedIndexes() {
|
||||||
DefaultPieceStorage pss(dctx_, option);
|
DefaultPieceStorage pss(dctx_, option_.get());
|
||||||
pss.setPieceSelector(pieceSelector_);
|
pss.setPieceSelector(pieceSelector_);
|
||||||
peer->setAllBitfield();
|
peer->setAllBitfield();
|
||||||
std::vector<size_t> excludedIndexes;
|
std::vector<size_t> excludedIndexes;
|
||||||
|
@ -165,7 +161,7 @@ void DefaultPieceStorageTest::testGetMissingPiece_manyWithExcludedIndexes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultPieceStorageTest::testGetMissingFastPiece() {
|
void DefaultPieceStorageTest::testGetMissingFastPiece() {
|
||||||
DefaultPieceStorage pss(dctx_, option);
|
DefaultPieceStorage pss(dctx_, option_.get());
|
||||||
pss.setPieceSelector(pieceSelector_);
|
pss.setPieceSelector(pieceSelector_);
|
||||||
pss.setEndGamePieceNum(0);
|
pss.setEndGamePieceNum(0);
|
||||||
|
|
||||||
|
@ -182,7 +178,7 @@ void DefaultPieceStorageTest::testGetMissingFastPiece() {
|
||||||
|
|
||||||
void DefaultPieceStorageTest::testGetMissingFastPiece_excludedIndexes()
|
void DefaultPieceStorageTest::testGetMissingFastPiece_excludedIndexes()
|
||||||
{
|
{
|
||||||
DefaultPieceStorage pss(dctx_, option);
|
DefaultPieceStorage pss(dctx_, option_.get());
|
||||||
pss.setPieceSelector(pieceSelector_);
|
pss.setPieceSelector(pieceSelector_);
|
||||||
pss.setEndGamePieceNum(0);
|
pss.setEndGamePieceNum(0);
|
||||||
|
|
||||||
|
@ -202,7 +198,7 @@ void DefaultPieceStorageTest::testGetMissingFastPiece_excludedIndexes()
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultPieceStorageTest::testHasMissingPiece() {
|
void DefaultPieceStorageTest::testHasMissingPiece() {
|
||||||
DefaultPieceStorage pss(dctx_, option);
|
DefaultPieceStorage pss(dctx_, option_.get());
|
||||||
|
|
||||||
CPPUNIT_ASSERT(!pss.hasMissingPiece(peer));
|
CPPUNIT_ASSERT(!pss.hasMissingPiece(peer));
|
||||||
|
|
||||||
|
@ -212,7 +208,7 @@ void DefaultPieceStorageTest::testHasMissingPiece() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultPieceStorageTest::testCompletePiece() {
|
void DefaultPieceStorageTest::testCompletePiece() {
|
||||||
DefaultPieceStorage pss(dctx_, option);
|
DefaultPieceStorage pss(dctx_, option_.get());
|
||||||
pss.setPieceSelector(pieceSelector_);
|
pss.setPieceSelector(pieceSelector_);
|
||||||
pss.setEndGamePieceNum(0);
|
pss.setEndGamePieceNum(0);
|
||||||
|
|
||||||
|
@ -234,7 +230,7 @@ void DefaultPieceStorageTest::testCompletePiece() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultPieceStorageTest::testGetPiece() {
|
void DefaultPieceStorageTest::testGetPiece() {
|
||||||
DefaultPieceStorage pss(dctx_, option);
|
DefaultPieceStorage pss(dctx_, option_.get());
|
||||||
|
|
||||||
SharedHandle<Piece> pieceGot = pss.getPiece(0);
|
SharedHandle<Piece> pieceGot = pss.getPiece(0);
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)0, pieceGot->getIndex());
|
CPPUNIT_ASSERT_EQUAL((size_t)0, pieceGot->getIndex());
|
||||||
|
@ -243,7 +239,7 @@ void DefaultPieceStorageTest::testGetPiece() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultPieceStorageTest::testGetPieceInUsedPieces() {
|
void DefaultPieceStorageTest::testGetPieceInUsedPieces() {
|
||||||
DefaultPieceStorage pss(dctx_, option);
|
DefaultPieceStorage pss(dctx_, option_.get());
|
||||||
SharedHandle<Piece> piece = SharedHandle<Piece>(new Piece(0, 128));
|
SharedHandle<Piece> piece = SharedHandle<Piece>(new Piece(0, 128));
|
||||||
piece->completeBlock(0);
|
piece->completeBlock(0);
|
||||||
pss.addUsedPiece(piece);
|
pss.addUsedPiece(piece);
|
||||||
|
@ -254,7 +250,7 @@ void DefaultPieceStorageTest::testGetPieceInUsedPieces() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultPieceStorageTest::testGetPieceCompletedPiece() {
|
void DefaultPieceStorageTest::testGetPieceCompletedPiece() {
|
||||||
DefaultPieceStorage pss(dctx_, option);
|
DefaultPieceStorage pss(dctx_, option_.get());
|
||||||
SharedHandle<Piece> piece = SharedHandle<Piece>(new Piece(0, 128));
|
SharedHandle<Piece> piece = SharedHandle<Piece>(new Piece(0, 128));
|
||||||
pss.completePiece(piece);
|
pss.completePiece(piece);
|
||||||
SharedHandle<Piece> pieceGot = pss.getPiece(0);
|
SharedHandle<Piece> pieceGot = pss.getPiece(0);
|
||||||
|
@ -274,7 +270,7 @@ void DefaultPieceStorageTest::testCancelPiece()
|
||||||
SharedHandle<DownloadContext> dctx
|
SharedHandle<DownloadContext> dctx
|
||||||
(new DownloadContext(pieceLength, totalLength, "src/file1.txt"));
|
(new DownloadContext(pieceLength, totalLength, "src/file1.txt"));
|
||||||
|
|
||||||
SharedHandle<DefaultPieceStorage> ps(new DefaultPieceStorage(dctx, option));
|
SharedHandle<DefaultPieceStorage> ps(new DefaultPieceStorage(dctx, option_.get()));
|
||||||
|
|
||||||
SharedHandle<Piece> p = ps->getMissingPiece(0);
|
SharedHandle<Piece> p = ps->getMissingPiece(0);
|
||||||
p->completeBlock(0);
|
p->completeBlock(0);
|
||||||
|
@ -293,7 +289,7 @@ void DefaultPieceStorageTest::testMarkPiecesDone()
|
||||||
SharedHandle<DownloadContext> dctx
|
SharedHandle<DownloadContext> dctx
|
||||||
(new DownloadContext(pieceLength, totalLength));
|
(new DownloadContext(pieceLength, totalLength));
|
||||||
|
|
||||||
DefaultPieceStorage ps(dctx, option);
|
DefaultPieceStorage ps(dctx, option_.get());
|
||||||
|
|
||||||
ps.markPiecesDone(pieceLength*10+16*1024*2+1);
|
ps.markPiecesDone(pieceLength*10+16*1024*2+1);
|
||||||
|
|
||||||
|
@ -320,7 +316,7 @@ void DefaultPieceStorageTest::testGetCompletedLength()
|
||||||
SharedHandle<DownloadContext> dctx
|
SharedHandle<DownloadContext> dctx
|
||||||
(new DownloadContext(1024*1024, 256*1024*1024));
|
(new DownloadContext(1024*1024, 256*1024*1024));
|
||||||
|
|
||||||
DefaultPieceStorage ps(dctx, option);
|
DefaultPieceStorage ps(dctx, option_.get());
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL((uint64_t)0, ps.getCompletedLength());
|
CPPUNIT_ASSERT_EQUAL((uint64_t)0, ps.getCompletedLength());
|
||||||
|
|
||||||
|
@ -347,7 +343,7 @@ void DefaultPieceStorageTest::testGetCompletedLength()
|
||||||
|
|
||||||
void DefaultPieceStorageTest::testGetNextUsedIndex()
|
void DefaultPieceStorageTest::testGetNextUsedIndex()
|
||||||
{
|
{
|
||||||
DefaultPieceStorage pss(dctx_, option);
|
DefaultPieceStorage pss(dctx_, option_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)3, pss.getNextUsedIndex(0));
|
CPPUNIT_ASSERT_EQUAL((size_t)3, pss.getNextUsedIndex(0));
|
||||||
SharedHandle<Piece> piece = pss.getMissingPiece(2);
|
SharedHandle<Piece> piece = pss.getMissingPiece(2);
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, pss.getNextUsedIndex(0));
|
CPPUNIT_ASSERT_EQUAL((size_t)2, pss.getNextUsedIndex(0));
|
||||||
|
|
|
@ -71,9 +71,6 @@ void DownloadContextTest::testGetBasePath()
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string(""), ctx.getBasePath());
|
CPPUNIT_ASSERT_EQUAL(std::string(""), ctx.getBasePath());
|
||||||
ctx.getFirstFileEntry()->setPath("aria2.tar.bz2");
|
ctx.getFirstFileEntry()->setPath("aria2.tar.bz2");
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2.tar.bz2"), ctx.getBasePath());
|
CPPUNIT_ASSERT_EQUAL(std::string("aria2.tar.bz2"), ctx.getBasePath());
|
||||||
ctx.setDir("/tmp");
|
|
||||||
// See dir doesn't effect getBasePath().
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2.tar.bz2"), ctx.getBasePath());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -91,7 +91,6 @@ void DownloadHelperTest::testCreateRequestGroupForUri()
|
||||||
}
|
}
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)7, group->getNumConcurrentCommand());
|
CPPUNIT_ASSERT_EQUAL((unsigned int)7, group->getNumConcurrentCommand());
|
||||||
SharedHandle<DownloadContext> ctx = group->getDownloadContext();
|
SharedHandle<DownloadContext> ctx = group->getDownloadContext();
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp"), ctx->getDir());
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/file.out"), ctx->getBasePath());
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/file.out"), ctx->getBasePath());
|
||||||
}
|
}
|
||||||
option_->put(PREF_SPLIT, "5");
|
option_->put(PREF_SPLIT, "5");
|
||||||
|
@ -136,7 +135,6 @@ void DownloadHelperTest::testCreateRequestGroupForUri()
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)2,
|
CPPUNIT_ASSERT_EQUAL((unsigned int)2,
|
||||||
alphaGroup->getNumConcurrentCommand());
|
alphaGroup->getNumConcurrentCommand());
|
||||||
SharedHandle<DownloadContext> alphaCtx = alphaGroup->getDownloadContext();
|
SharedHandle<DownloadContext> alphaCtx = alphaGroup->getDownloadContext();
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp"), alphaCtx->getDir());
|
|
||||||
// See filename is not assigned yet
|
// See filename is not assigned yet
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string(""), alphaCtx->getBasePath());
|
CPPUNIT_ASSERT_EQUAL(std::string(""), alphaCtx->getBasePath());
|
||||||
}
|
}
|
||||||
|
@ -171,7 +169,6 @@ void DownloadHelperTest::testCreateRequestGroupForUri_parameterized()
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)3, group->getNumConcurrentCommand());
|
CPPUNIT_ASSERT_EQUAL((unsigned int)3, group->getNumConcurrentCommand());
|
||||||
SharedHandle<DownloadContext> ctx = group->getDownloadContext();
|
SharedHandle<DownloadContext> ctx = group->getDownloadContext();
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp"), ctx->getDir());
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/file.out"), ctx->getBasePath());
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/file.out"), ctx->getBasePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,7 +204,6 @@ void DownloadHelperTest::testCreateRequestGroupForUri_BitTorrent()
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)3, group->getNumConcurrentCommand());
|
CPPUNIT_ASSERT_EQUAL((unsigned int)3, group->getNumConcurrentCommand());
|
||||||
SharedHandle<DownloadContext> ctx = group->getDownloadContext();
|
SharedHandle<DownloadContext> ctx = group->getDownloadContext();
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp"), ctx->getDir());
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/file.out"),
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/file.out"),
|
||||||
ctx->getBasePath());
|
ctx->getBasePath());
|
||||||
|
|
||||||
|
@ -218,7 +214,6 @@ void DownloadHelperTest::testCreateRequestGroupForUri_BitTorrent()
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)3,
|
CPPUNIT_ASSERT_EQUAL((unsigned int)3,
|
||||||
torrentGroup->getNumConcurrentCommand());
|
torrentGroup->getNumConcurrentCommand());
|
||||||
SharedHandle<DownloadContext> btctx = torrentGroup->getDownloadContext();
|
SharedHandle<DownloadContext> btctx = torrentGroup->getDownloadContext();
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp"), btctx->getDir());
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-test"),
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-test"),
|
||||||
btctx->getBasePath());
|
btctx->getBasePath());
|
||||||
}
|
}
|
||||||
|
@ -262,7 +257,6 @@ void DownloadHelperTest::testCreateRequestGroupForUri_Metalink()
|
||||||
}
|
}
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)3, group->getNumConcurrentCommand());
|
CPPUNIT_ASSERT_EQUAL((unsigned int)3, group->getNumConcurrentCommand());
|
||||||
SharedHandle<DownloadContext> ctx = group->getDownloadContext();
|
SharedHandle<DownloadContext> ctx = group->getDownloadContext();
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp"), ctx->getDir());
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/file.out"),
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/file.out"),
|
||||||
ctx->getBasePath());
|
ctx->getBasePath());
|
||||||
|
|
||||||
|
@ -271,7 +265,6 @@ void DownloadHelperTest::testCreateRequestGroupForUri_Metalink()
|
||||||
aria2052Group->getNumConcurrentCommand());
|
aria2052Group->getNumConcurrentCommand());
|
||||||
SharedHandle<DownloadContext> aria2052Ctx =
|
SharedHandle<DownloadContext> aria2052Ctx =
|
||||||
aria2052Group->getDownloadContext();
|
aria2052Group->getDownloadContext();
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp"), aria2052Ctx->getDir());
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-0.5.2.tar.bz2"),
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-0.5.2.tar.bz2"),
|
||||||
aria2052Ctx->getBasePath());
|
aria2052Ctx->getBasePath());
|
||||||
|
|
||||||
|
@ -304,13 +297,11 @@ void DownloadHelperTest::testCreateRequestGroupForUriList()
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://charlie/file"), fileURIs[2]);
|
CPPUNIT_ASSERT_EQUAL(std::string("http://charlie/file"), fileURIs[2]);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)3, fileGroup->getNumConcurrentCommand());
|
CPPUNIT_ASSERT_EQUAL((unsigned int)3, fileGroup->getNumConcurrentCommand());
|
||||||
SharedHandle<DownloadContext> fileCtx = fileGroup->getDownloadContext();
|
SharedHandle<DownloadContext> fileCtx = fileGroup->getDownloadContext();
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/mydownloads"), fileCtx->getDir());
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/mydownloads/myfile.out"),
|
CPPUNIT_ASSERT_EQUAL(std::string("/mydownloads/myfile.out"),
|
||||||
fileCtx->getBasePath());
|
fileCtx->getBasePath());
|
||||||
|
|
||||||
SharedHandle<RequestGroup> fileISOGroup = result[1];
|
SharedHandle<RequestGroup> fileISOGroup = result[1];
|
||||||
SharedHandle<DownloadContext> fileISOCtx = fileISOGroup->getDownloadContext();
|
SharedHandle<DownloadContext> fileISOCtx = fileISOGroup->getDownloadContext();
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp"), fileISOCtx->getDir());
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/file.out"),
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/file.out"),
|
||||||
fileISOCtx->getBasePath());
|
fileISOCtx->getBasePath());
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,6 @@ void Metalink2RequestGroupTest::testGenerate()
|
||||||
|
|
||||||
CPPUNIT_ASSERT(dctx);
|
CPPUNIT_ASSERT(dctx);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint64_t)0ULL, dctx->getTotalLength());
|
CPPUNIT_ASSERT_EQUAL((uint64_t)0ULL, dctx->getTotalLength());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp"), dctx->getDir());
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), dctx->getChecksumHashAlgo());
|
CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), dctx->getChecksumHashAlgo());
|
||||||
CPPUNIT_ASSERT_EQUAL
|
CPPUNIT_ASSERT_EQUAL
|
||||||
|
@ -79,7 +78,6 @@ void Metalink2RequestGroupTest::testGenerate()
|
||||||
const SharedHandle<DownloadContext>& dctx = rg->getDownloadContext();
|
const SharedHandle<DownloadContext>& dctx = rg->getDownloadContext();
|
||||||
|
|
||||||
CPPUNIT_ASSERT(dctx);
|
CPPUNIT_ASSERT(dctx);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp"), dctx->getDir());
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), dctx->getPieceHashAlgo());
|
CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), dctx->getPieceHashAlgo());
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, dctx->getPieceHashes().size());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, dctx->getPieceHashes().size());
|
||||||
|
@ -124,7 +122,6 @@ void Metalink2RequestGroupTest::testGenerate()
|
||||||
const SharedHandle<DownloadContext>& dctx = rg->getDownloadContext();
|
const SharedHandle<DownloadContext>& dctx = rg->getDownloadContext();
|
||||||
|
|
||||||
CPPUNIT_ASSERT(dctx);
|
CPPUNIT_ASSERT(dctx);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp"), dctx->getDir());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@ public:
|
||||||
void setUp()
|
void setUp()
|
||||||
{
|
{
|
||||||
option_.reset(new Option());
|
option_.reset(new Option());
|
||||||
option_->put("HELLO", "WORLD");
|
|
||||||
option_->put(PREF_DIR, A2_TEST_OUT_DIR);
|
option_->put(PREF_DIR, A2_TEST_OUT_DIR);
|
||||||
dctx_.reset(new DownloadContext(0, 0, A2_TEST_OUT_DIR"/something"));
|
dctx_.reset(new DownloadContext(0, 0, A2_TEST_OUT_DIR"/something"));
|
||||||
requestGroup_.reset(new RequestGroup(option_));
|
requestGroup_.reset(new RequestGroup(option_));
|
||||||
|
|
|
@ -177,7 +177,7 @@ void XmlRpcMethodTest::testAddUri()
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/sink"),
|
CPPUNIT_ASSERT_EQUAL(std::string("/sink"),
|
||||||
e_->getRequestGroupMan()->findReservedGroup(2)->
|
e_->getRequestGroupMan()->findReservedGroup(2)->
|
||||||
getDownloadContext()->getDir());
|
getOption()->get(PREF_DIR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -747,7 +747,6 @@ void XmlRpcMethodTest::testGatherProgressCommon()
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext(0, 0,"aria2.tar.bz2"));
|
SharedHandle<DownloadContext> dctx(new DownloadContext(0, 0,"aria2.tar.bz2"));
|
||||||
std::string uris[] = { "http://localhost/aria2.tar.bz2" };
|
std::string uris[] = { "http://localhost/aria2.tar.bz2" };
|
||||||
dctx->getFirstFileEntry()->addUris(vbegin(uris), vend(uris));
|
dctx->getFirstFileEntry()->addUris(vbegin(uris), vend(uris));
|
||||||
dctx->setDir(option_->get(PREF_DIR));
|
|
||||||
SharedHandle<RequestGroup> group(new RequestGroup(option_));
|
SharedHandle<RequestGroup> group(new RequestGroup(option_));
|
||||||
group->setDownloadContext(dctx);
|
group->setDownloadContext(dctx);
|
||||||
std::vector<SharedHandle<RequestGroup> > followedBy;
|
std::vector<SharedHandle<RequestGroup> > followedBy;
|
||||||
|
@ -794,8 +793,10 @@ void XmlRpcMethodTest::testGatherProgressCommon()
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
void XmlRpcMethodTest::testGatherBitTorrentMetadata()
|
void XmlRpcMethodTest::testGatherBitTorrentMetadata()
|
||||||
{
|
{
|
||||||
|
SharedHandle<Option> option(new Option());
|
||||||
|
option->put(PREF_DIR, ".");
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
bittorrent::load(A2_TEST_DIR"/test.torrent", dctx);
|
bittorrent::load(A2_TEST_DIR"/test.torrent", dctx, option);
|
||||||
SharedHandle<Dict> btDict = Dict::g();
|
SharedHandle<Dict> btDict = Dict::g();
|
||||||
gatherBitTorrentMetadata(btDict, bittorrent::getTorrentAttrs(dctx));
|
gatherBitTorrentMetadata(btDict, bittorrent::getTorrentAttrs(dctx));
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("REDNOAH.COM RULES"),
|
CPPUNIT_ASSERT_EQUAL(std::string("REDNOAH.COM RULES"),
|
||||||
|
|
Loading…
Reference in New Issue