mirror of https://github.com/aria2/aria2
Use SegList<int> instead of IntSequence in Metalink2RequestGroup.
parent
a6ea8531e7
commit
95586f594f
|
@ -56,6 +56,7 @@
|
||||||
#include "a2functional.h"
|
#include "a2functional.h"
|
||||||
#include "download_helper.h"
|
#include "download_helper.h"
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
|
#include "SegList.h"
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
# include "BtDependency.h"
|
# include "BtDependency.h"
|
||||||
# include "download_helper.h"
|
# include "download_helper.h"
|
||||||
|
@ -153,9 +154,6 @@ Metalink2RequestGroup::createRequestGroup
|
||||||
A2_LOG_NOTICE(EX_NO_RESULT_WITH_YOUR_PREFS);
|
A2_LOG_NOTICE(EX_NO_RESULT_WITH_YOUR_PREFS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::vector<int32_t> selectIndexes =
|
|
||||||
util::parseIntRange(optionTemplate->get(PREF_SELECT_FILE)).flush();
|
|
||||||
std::sort(selectIndexes.begin(), selectIndexes.end());
|
|
||||||
std::vector<std::string> locations;
|
std::vector<std::string> locations;
|
||||||
if(optionTemplate->defined(PREF_METALINK_LOCATION)) {
|
if(optionTemplate->defined(PREF_METALINK_LOCATION)) {
|
||||||
util::split(util::toLower(optionTemplate->get(PREF_METALINK_LOCATION)),
|
util::split(util::toLower(optionTemplate->get(PREF_METALINK_LOCATION)),
|
||||||
|
@ -165,12 +163,8 @@ Metalink2RequestGroup::createRequestGroup
|
||||||
if(optionTemplate->get(PREF_METALINK_PREFERRED_PROTOCOL) != V_NONE) {
|
if(optionTemplate->get(PREF_METALINK_PREFERRED_PROTOCOL) != V_NONE) {
|
||||||
preferredProtocol = optionTemplate->get(PREF_METALINK_PREFERRED_PROTOCOL);
|
preferredProtocol = optionTemplate->get(PREF_METALINK_PREFERRED_PROTOCOL);
|
||||||
}
|
}
|
||||||
std::vector<SharedHandle<MetalinkEntry> > selectedEntries;
|
|
||||||
selectedEntries.reserve(entries.size());
|
|
||||||
{
|
|
||||||
int32_t count = 1;
|
|
||||||
for(std::vector<SharedHandle<MetalinkEntry> >::const_iterator i =
|
for(std::vector<SharedHandle<MetalinkEntry> >::const_iterator i =
|
||||||
entries.begin(), eoi = entries.end(); i != eoi; ++i, ++count) {
|
entries.begin(), eoi = entries.end(); i != eoi; ++i) {
|
||||||
(*i)->dropUnsupportedResource();
|
(*i)->dropUnsupportedResource();
|
||||||
if((*i)->resources.empty() && (*i)->metaurls.empty()) {
|
if((*i)->resources.empty() && (*i)->metaurls.empty()) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -181,9 +175,20 @@ Metalink2RequestGroup::createRequestGroup
|
||||||
(*i)->setProtocolPriority
|
(*i)->setProtocolPriority
|
||||||
(preferredProtocol, -MetalinkResource::getLowestPriority());
|
(preferredProtocol, -MetalinkResource::getLowestPriority());
|
||||||
}
|
}
|
||||||
if(selectIndexes.empty() ||
|
}
|
||||||
std::binary_search(selectIndexes.begin(), selectIndexes.end(), count)){
|
std::vector<SharedHandle<MetalinkEntry> > selectedEntries;
|
||||||
selectedEntries.push_back(*i);
|
SegList<int> sgl;
|
||||||
|
util::parseIntSegments(sgl, optionTemplate->get(PREF_SELECT_FILE));
|
||||||
|
sgl.normalize();
|
||||||
|
if(!sgl.hasNext()) {
|
||||||
|
selectedEntries.assign(entries.begin(), entries.end());
|
||||||
|
} else {
|
||||||
|
selectedEntries.reserve(entries.size());
|
||||||
|
for(size_t i = 0, len = entries.size(); i < len && sgl.hasNext(); ++i) {
|
||||||
|
size_t j = sgl.peek()-1;
|
||||||
|
if(i == j) {
|
||||||
|
selectedEntries.push_back(entries[i]);
|
||||||
|
sgl.next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue