diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-11-28 09:58:49 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-11-28 09:58:49 +0000 |
| commit | 339795311bd3d07da1d49fb2c5c2e7efa8833922 (patch) | |
| tree | 21c4960e2cb6a04933f70d784351d15c64223605 /src/UTMetadataPostDownloadHandler.cc | |
| parent | 96205abc67e5f425e3bad997959493ba54d83190 (diff) | |
2009-11-28 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Accept BitTorrent Magnet URI in Metalink resource type bittorrent.
Rewritten UTMetadataPostDownloadHandler. To create torrent data
from metadata, use new metadata2Torrent() function.
* src/BtDependency.cc
* src/UTMetadataPostDownloadHandler.cc
* src/bittorrent_helper.cc
* src/bittorrent_helper.h
* test/BittorrentHelperTest.cc
* test/BtDependencyTest.cc
Diffstat (limited to 'src/UTMetadataPostDownloadHandler.cc')
| -rw-r--r-- | src/UTMetadataPostDownloadHandler.cc | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/src/UTMetadataPostDownloadHandler.cc b/src/UTMetadataPostDownloadHandler.cc index 90ced69f..12e0f9dc 100644 --- a/src/UTMetadataPostDownloadHandler.cc +++ b/src/UTMetadataPostDownloadHandler.cc @@ -45,6 +45,7 @@ #include "a2functional.h" #include "DiskAdaptor.h" #include "PieceStorage.h" +#include "bencode.h" namespace aria2 { @@ -72,35 +73,13 @@ void UTMetadataPostDownloadHandler::getNextRequestGroups { SharedHandle<DownloadContext> dctx = requestGroup->getDownloadContext(); const BDE& attrs = dctx->getAttribute(bittorrent::BITTORRENT); - std::string torrent = - strconcat("d4:info", - util::toString(requestGroup->getPieceStorage()->getDiskAdaptor()), - "e"); + std::string metadata = + util::toString(requestGroup->getPieceStorage()->getDiskAdaptor()); + std::string torrent = bittorrent::metadata2Torrent(metadata, attrs); try { std::deque<SharedHandle<RequestGroup> > newRgs; createRequestGroupForBitTorrent(newRgs, requestGroup->getOption(), std::deque<std::string>(), torrent); - if(attrs.containsKey(bittorrent::ANNOUNCE_LIST)) { - for(std::deque<SharedHandle<RequestGroup> >::const_iterator i = - newRgs.begin(); i != newRgs.end(); ++i) { - SharedHandle<DownloadContext> newDctx = (*i)->getDownloadContext(); - if(!newDctx->hasAttribute(bittorrent::BITTORRENT)) { - continue; - } - BDE& newAttrs = newDctx->getAttribute(bittorrent::BITTORRENT); - if(attrs[bittorrent::INFO_HASH].s() != - newAttrs[bittorrent::INFO_HASH].s()) { - continue; - } - assert(newAttrs[bittorrent::ANNOUNCE_LIST].isList()); - if(newAttrs[bittorrent::ANNOUNCE_LIST].size() == 0) { - newAttrs[bittorrent::ANNOUNCE_LIST] = - attrs[bittorrent::ANNOUNCE_LIST]; - } - break; - } - } - groups.insert(groups.end(), newRgs.begin(), newRgs.end()); } catch(RecoverableException& e) { _logger->error("Failed to parse BitTorrent metadata.", e); |
