summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-04-26 08:12:46 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-04-26 08:12:46 +0000
commita7952cce05a41c6e20d6eddc569a8bffe974aade (patch)
tree25e9348698ac2c6685cb5fa4dbb051d58fa040ae /src
parent8678e1f380a4bd1d964d04f4ed4ad6d7373279ea (diff)
2008-04-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Now auto protocol detection is enabled without -Z option. But there is a important difference between with/without -Z optoin. For example, if you type: aria2c http://host/file file1.torrent file2.metalink http://mirror/file then, aria2 interprets there are 3 request groups: (1) http://host/file, http://mirror/file <-- multi-source download (2) file1.torrent (3) file2.metalink On the other hand, if you invoke above command with -Z option, it is interpreted as 4 request groups: (1) http://host/file (2) file1.torrent (3) file2.metalink (4) http://mirror/file I think usually user don't mix multi-source URLs and torrent files, so there is no big problem here. * src/main.cc
Diffstat (limited to 'src')
-rw-r--r--src/main.cc26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/main.cc b/src/main.cc
index 7a8801f3..4db1226e 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -293,6 +293,15 @@ int32_t downloadUriList(Option* op)
}
}
+class StreamProtocolFilter {
+private:
+ ProtocolDetector _detector;
+public:
+ bool operator()(const std::string& uri) {
+ return _detector.isStreamProtocol(uri);
+ }
+};
+
int32_t downloadUri(Option* op, const std::deque<std::string>& uris)
{
std::deque<std::string> nargs;
@@ -307,11 +316,22 @@ int32_t downloadUri(Option* op, const std::deque<std::string>& uris)
std::deque<SharedHandle<RequestGroup> >(),
AccRequestGroup(op));
} else {
+ std::deque<std::string>::iterator strmProtoEnd =
+ std::stable_partition(nargs.begin(), nargs.end(), StreamProtocolFilter());
+ // let's process http/ftp protocols first.
std::deque<std::string> xargs;
- ncopy(nargs.begin(), nargs.end(), op->getAsInt(PREF_SPLIT),
+ ncopy(nargs.begin(), strmProtoEnd, op->getAsInt(PREF_SPLIT),
std::back_inserter(xargs));
- RequestGroupHandle rg = createRequestGroup(op, xargs, op->get(PREF_OUT));
- groups.push_back(rg);
+ if(xargs.size()) {
+ RequestGroupHandle rg = createRequestGroup(op, xargs, op->get(PREF_OUT));
+ groups.push_back(rg);
+ }
+ // process remaining URIs(local metalink, BitTorrent files)
+ std::deque<SharedHandle<RequestGroup> > remGroups =
+ std::accumulate(strmProtoEnd, nargs.end(),
+ std::deque<SharedHandle<RequestGroup> >(),
+ AccRequestGroup(op));
+ groups.insert(groups.end(), remGroups.begin(), remGroups.end());
}
return MultiUrlRequestInfo(groups, op, getStatCalc(op), getSummaryOut(op)).execute();
}