mirror of https://github.com/aria2/aria2
Apply PREF_MAX_CONNECTION_PER_SERVER to BitTorrent WEB Seeding hosts.
parent
e2e711fba8
commit
9e2624a265
|
@ -225,6 +225,7 @@ void extractFileEntries
|
||||||
utf8Name = overrideName;
|
utf8Name = overrideName;
|
||||||
}
|
}
|
||||||
torrent->name = utf8Name;
|
torrent->name = utf8Name;
|
||||||
|
int maxConn = option->getAsInt(PREF_MAX_CONNECTION_PER_SERVER);
|
||||||
std::vector<SharedHandle<FileEntry> > fileEntries;
|
std::vector<SharedHandle<FileEntry> > fileEntries;
|
||||||
const List* filesList = downcast<List>(infoDict->get(C_FILES));
|
const List* filesList = downcast<List>(infoDict->get(C_FILES));
|
||||||
if(filesList) {
|
if(filesList) {
|
||||||
|
@ -289,6 +290,7 @@ void extractFileEntries
|
||||||
util::escapePath(utf8Path)),
|
util::escapePath(utf8Path)),
|
||||||
fileLengthData->i(), offset, uris));
|
fileLengthData->i(), offset, uris));
|
||||||
fileEntry->setOriginalName(utf8Path);
|
fileEntry->setOriginalName(utf8Path);
|
||||||
|
fileEntry->setMaxConnectionPerServer(maxConn);
|
||||||
fileEntries.push_back(fileEntry);
|
fileEntries.push_back(fileEntry);
|
||||||
offset += fileEntry->getLength();
|
offset += fileEntry->getLength();
|
||||||
}
|
}
|
||||||
|
@ -318,6 +320,7 @@ void extractFileEntries
|
||||||
util::escapePath(utf8Name)),
|
util::escapePath(utf8Name)),
|
||||||
totalLength, 0, uris));
|
totalLength, 0, uris));
|
||||||
fileEntry->setOriginalName(utf8Name);
|
fileEntry->setOriginalName(utf8Name);
|
||||||
|
fileEntry->setMaxConnectionPerServer(maxConn);
|
||||||
fileEntries.push_back(fileEntry);
|
fileEntries.push_back(fileEntry);
|
||||||
}
|
}
|
||||||
ctx->setFileEntries(fileEntries.begin(), fileEntries.end());
|
ctx->setFileEntries(fileEntries.begin(), fileEntries.end());
|
||||||
|
|
|
@ -162,6 +162,7 @@ void BittorrentHelperTest::testGetPieceHash() {
|
||||||
|
|
||||||
void BittorrentHelperTest::testGetFileEntries() {
|
void BittorrentHelperTest::testGetFileEntries() {
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
|
option_->put(PREF_MAX_CONNECTION_PER_SERVER, "10");
|
||||||
load(A2_TEST_DIR"/test.torrent", dctx, option_);
|
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();
|
||||||
|
@ -174,14 +175,17 @@ void BittorrentHelperTest::testGetFileEntries() {
|
||||||
fileEntry1->getPath());
|
fileEntry1->getPath());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2-test/aria2/src/aria2c"),
|
CPPUNIT_ASSERT_EQUAL(std::string("aria2-test/aria2/src/aria2c"),
|
||||||
fileEntry1->getOriginalName());
|
fileEntry1->getOriginalName());
|
||||||
|
CPPUNIT_ASSERT_EQUAL((size_t)10, fileEntry1->getMaxConnectionPerServer());
|
||||||
itr++;
|
itr++;
|
||||||
SharedHandle<FileEntry> fileEntry2 = *itr;
|
SharedHandle<FileEntry> fileEntry2 = *itr;
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("./aria2-test/aria2-0.2.2.tar.bz2"),
|
CPPUNIT_ASSERT_EQUAL(std::string("./aria2-test/aria2-0.2.2.tar.bz2"),
|
||||||
fileEntry2->getPath());
|
fileEntry2->getPath());
|
||||||
|
CPPUNIT_ASSERT_EQUAL((size_t)10, fileEntry2->getMaxConnectionPerServer());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BittorrentHelperTest::testGetFileEntriesSingle() {
|
void BittorrentHelperTest::testGetFileEntriesSingle() {
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||||
|
option_->put(PREF_MAX_CONNECTION_PER_SERVER, "10");
|
||||||
load(A2_TEST_DIR"/single.torrent", dctx, option_);
|
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();
|
||||||
|
@ -194,6 +198,7 @@ void BittorrentHelperTest::testGetFileEntriesSingle() {
|
||||||
fileEntry1->getPath());
|
fileEntry1->getPath());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2-0.8.2.tar.bz2"),
|
CPPUNIT_ASSERT_EQUAL(std::string("aria2-0.8.2.tar.bz2"),
|
||||||
fileEntry1->getOriginalName());
|
fileEntry1->getOriginalName());
|
||||||
|
CPPUNIT_ASSERT_EQUAL((size_t)10, fileEntry1->getMaxConnectionPerServer());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BittorrentHelperTest::testGetTotalLength() {
|
void BittorrentHelperTest::testGetTotalLength() {
|
||||||
|
|
Loading…
Reference in New Issue