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
pull/1/head
Tatsuhiro Tsujikawa 2008-04-26 08:12:46 +00:00
parent 8678e1f380
commit a7952cce05
2 changed files with 46 additions and 3 deletions

View File

@ -1,3 +1,26 @@
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
2008-04-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed the bug that causes segmentaion fault when reading XML containing

View File

@ -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,12 +316,23 @@ 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));
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();
}