mirror of https://github.com/aria2/aria2
Shuffle web-seeding URIs
parent
f910c6f782
commit
4cf0bb742f
|
@ -49,6 +49,7 @@
|
|||
#include "DlAbortEx.h"
|
||||
#include "fmt.h"
|
||||
#include "FileEntry.h"
|
||||
#include "SimpleRandomizer.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -117,6 +118,11 @@ bool BtDependency::resolve()
|
|||
}
|
||||
const std::vector<std::shared_ptr<FileEntry> >& fileEntries =
|
||||
context->getFileEntries();
|
||||
for (auto &fe : fileEntries) {
|
||||
auto &uri = fe->getRemainingUris();
|
||||
std::random_shuffle(std::begin(uri), std::end(uri),
|
||||
*SimpleRandomizer::getInstance());
|
||||
}
|
||||
const std::vector<std::shared_ptr<FileEntry> >& dependantFileEntries =
|
||||
dependant_->getDownloadContext()->getFileEntries();
|
||||
// If dependant's FileEntry::getOriginalName() is empty, we
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
#include "OptionParser.h"
|
||||
#include "SegList.h"
|
||||
#include "download_handlers.h"
|
||||
#include "SimpleRandomizer.h"
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
# include "bittorrent_helper.h"
|
||||
# include "BtConstants.h"
|
||||
|
@ -197,6 +198,11 @@ createBtRequestGroup(const std::string& metaInfoUri,
|
|||
// may throw exception
|
||||
bittorrent::loadFromMemory(torrent, dctx, option, auxUris,
|
||||
metaInfoUri.empty() ? "default" : metaInfoUri);
|
||||
for (auto &fe : dctx->getFileEntries()) {
|
||||
auto &uris = fe->getRemainingUris();
|
||||
std::random_shuffle(std::begin(uris), std::end(uris),
|
||||
*SimpleRandomizer::getInstance());
|
||||
}
|
||||
if(metaInfoUri.empty()) {
|
||||
rg->setMetadataInfo(createMetadataInfoDataOnly());
|
||||
} else {
|
||||
|
|
|
@ -324,6 +324,7 @@ void DownloadHelperTest::testCreateRequestGroupForBitTorrent()
|
|||
std::shared_ptr<RequestGroup> group = result[0];
|
||||
auto uris =
|
||||
group->getDownloadContext()->getFirstFileEntry()->getUris();
|
||||
std::sort(std::begin(uris), std::end(uris));
|
||||
// See -s option is ignored. See processRootDictionary() in
|
||||
// bittorrent_helper.cc
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)3, uris.size());
|
||||
|
|
Loading…
Reference in New Issue