mirror of https://github.com/aria2/aria2
2008-06-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Changed -s options behavior. Now it means the number of connections made simultaneously in each http/ftp download. If 1 URL is specified, the behavior is the same with old implementation. If -s N is given and more than N URLs are specified, first N URLs are used and remaining URLs are used for backup. If less than N URLs are specified, some of URLs are used more than once so that totally N connections are made simultaneously. * src/main.ccpull/1/head
parent
b68fa9ea33
commit
32edb40d7d
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2008-06-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
Changed -s options behavior. Now it means the number of connections
|
||||||
|
made simultaneously in each http/ftp download.
|
||||||
|
If 1 URL is specified, the behavior is the same with old implementation.
|
||||||
|
If -s N is given and more than N URLs are specified, first N URLs are
|
||||||
|
used and remaining URLs are used for backup. If less than N URLs are
|
||||||
|
specified, some of URLs are used more than once so that totally N
|
||||||
|
connections are made simultaneously.
|
||||||
|
* src/main.cc
|
||||||
|
|
||||||
2008-06-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2008-06-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
Included missing iosfwd or ostream header.
|
Included missing iosfwd or ostream header.
|
||||||
|
|
67
src/main.cc
67
src/main.cc
|
@ -168,23 +168,32 @@ createBtRequestGroup(const std::string& torrentFilePath,
|
||||||
return rg;
|
return rg;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t downloadBitTorrent(Option* op, const std::deque<std::string>& uri)
|
int32_t downloadBitTorrent(Option* op, const std::deque<std::string>& uris)
|
||||||
{
|
{
|
||||||
std::deque<std::string> nargs;
|
std::deque<std::string> nargs;
|
||||||
if(op->get(PREF_PARAMETERIZED_URI) == V_TRUE) {
|
if(op->get(PREF_PARAMETERIZED_URI) == V_TRUE) {
|
||||||
nargs = unfoldURI(uri);
|
nargs = unfoldURI(uris);
|
||||||
} else {
|
} else {
|
||||||
nargs = uri;
|
nargs = uris;
|
||||||
}
|
}
|
||||||
std::deque<std::string> xargs;
|
|
||||||
ncopy(nargs.begin(), nargs.end(), op->getAsInt(PREF_SPLIT),
|
|
||||||
std::back_inserter(xargs));
|
|
||||||
|
|
||||||
RequestGroupHandle rg = createBtRequestGroup(op->get(PREF_TORRENT_FILE),
|
|
||||||
op, xargs);
|
|
||||||
|
|
||||||
RequestGroups groups;
|
RequestGroups groups;
|
||||||
groups.push_back(rg);
|
size_t numSplit = op->getAsInt(PREF_SPLIT);
|
||||||
|
if(nargs.size() >= numSplit) {
|
||||||
|
RequestGroupHandle rg = createBtRequestGroup(op->get(PREF_TORRENT_FILE),
|
||||||
|
op, nargs);
|
||||||
|
rg->setNumConcurrentCommand(numSplit);
|
||||||
|
groups.push_back(rg);
|
||||||
|
} else {
|
||||||
|
std::deque<std::string> xargs;
|
||||||
|
if(!nargs.empty()) {
|
||||||
|
ncopy(nargs.begin(), nargs.end(), numSplit, std::back_inserter(xargs));
|
||||||
|
xargs.erase(xargs.begin()+numSplit, xargs.end());
|
||||||
|
}
|
||||||
|
RequestGroupHandle rg = createBtRequestGroup(op->get(PREF_TORRENT_FILE),
|
||||||
|
op, xargs);
|
||||||
|
rg->setNumConcurrentCommand(numSplit);
|
||||||
|
groups.push_back(rg);
|
||||||
|
}
|
||||||
return MultiUrlRequestInfo(groups, op, getStatCalc(op), getSummaryOut(op)).execute();
|
return MultiUrlRequestInfo(groups, op, getStatCalc(op), getSummaryOut(op)).execute();
|
||||||
}
|
}
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
|
@ -263,12 +272,20 @@ int32_t downloadUriList(Option* op, std::istream& in)
|
||||||
AccRequestGroup(groups, op));
|
AccRequestGroup(groups, op));
|
||||||
} else if(uris.size() == 1) {
|
} else if(uris.size() == 1) {
|
||||||
std::for_each(uris.begin(), uris.end(), AccRequestGroup(groups, op));
|
std::for_each(uris.begin(), uris.end(), AccRequestGroup(groups, op));
|
||||||
} else if(uris.size() > 0) {
|
} else if(!uris.empty()) {
|
||||||
std::deque<std::string> xuris;
|
size_t numSplit = op->getAsInt(PREF_SPLIT);
|
||||||
ncopy(uris.begin(), uris.end(), op->getAsInt(PREF_SPLIT),
|
if(uris.size() >= numSplit) {
|
||||||
std::back_inserter(xuris));
|
SharedHandle<RequestGroup> rg = createRequestGroup(op, uris);
|
||||||
SharedHandle<RequestGroup> rg = createRequestGroup(op, xuris);
|
rg->setNumConcurrentCommand(numSplit);
|
||||||
groups.push_back(rg);
|
groups.push_back(rg);
|
||||||
|
} else {
|
||||||
|
std::deque<std::string> xuris;
|
||||||
|
ncopy(uris.begin(), uris.end(), numSplit, std::back_inserter(xuris));
|
||||||
|
xuris.erase(xuris.begin()+numSplit, xuris.end());
|
||||||
|
SharedHandle<RequestGroup> rg = createRequestGroup(op, xuris);
|
||||||
|
rg->setNumConcurrentCommand(numSplit);
|
||||||
|
groups.push_back(rg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return MultiUrlRequestInfo(groups, op, getStatCalc(op), getSummaryOut(op)).execute();
|
return MultiUrlRequestInfo(groups, op, getStatCalc(op), getSummaryOut(op)).execute();
|
||||||
|
@ -313,11 +330,19 @@ int32_t downloadUri(Option* op, const std::deque<std::string>& uris)
|
||||||
std::deque<std::string>::iterator strmProtoEnd =
|
std::deque<std::string>::iterator strmProtoEnd =
|
||||||
std::stable_partition(nargs.begin(), nargs.end(), StreamProtocolFilter());
|
std::stable_partition(nargs.begin(), nargs.end(), StreamProtocolFilter());
|
||||||
// let's process http/ftp protocols first.
|
// let's process http/ftp protocols first.
|
||||||
std::deque<std::string> xargs;
|
size_t numSplit = op->getAsInt(PREF_SPLIT);
|
||||||
ncopy(nargs.begin(), strmProtoEnd, op->getAsInt(PREF_SPLIT),
|
size_t numURIs = std::distance(nargs.begin(), strmProtoEnd);
|
||||||
std::back_inserter(xargs));
|
if(numURIs >= numSplit) {
|
||||||
if(xargs.size()) {
|
std::deque<std::string> xargs(nargs.begin(), strmProtoEnd);
|
||||||
RequestGroupHandle rg = createRequestGroup(op, xargs, op->get(PREF_OUT));
|
RequestGroupHandle rg = createRequestGroup(op, xargs, op->get(PREF_OUT));
|
||||||
|
rg->setNumConcurrentCommand(numSplit);
|
||||||
|
groups.push_back(rg);
|
||||||
|
} else if(numURIs > 0) {
|
||||||
|
std::deque<std::string> xargs;
|
||||||
|
ncopy(nargs.begin(), strmProtoEnd, numSplit, std::back_inserter(xargs));
|
||||||
|
xargs.erase(xargs.begin()+numSplit, xargs.end());
|
||||||
|
RequestGroupHandle rg = createRequestGroup(op, xargs, op->get(PREF_OUT));
|
||||||
|
rg->setNumConcurrentCommand(numSplit);
|
||||||
groups.push_back(rg);
|
groups.push_back(rg);
|
||||||
}
|
}
|
||||||
// process remaining URIs(local metalink, BitTorrent files)
|
// process remaining URIs(local metalink, BitTorrent files)
|
||||||
|
|
Loading…
Reference in New Issue