diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-04-27 06:55:10 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-04-27 06:55:10 +0000 |
| commit | d58742ad21407362db34d508ceef8b7b21088bb1 (patch) | |
| tree | 6768dc11a4cb760781654eaf2279e13557898c39 /src | |
| parent | 1ea7fca02b99437b14d01d76597f3fc730f8282e (diff) | |
2009-04-27 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Use url-list (web-seeding) only for single-file torrent. This
is basically the same behavior with Metalink file with torrent
and URIs.
* src/RequestGroup.cc
* src/DefaultBtContext.cc
* test/DefaultBtContextTest.cc
Diffstat (limited to 'src')
| -rw-r--r-- | src/DefaultBtContext.cc | 15 | ||||
| -rw-r--r-- | src/RequestGroup.cc | 6 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/DefaultBtContext.cc b/src/DefaultBtContext.cc index 1f6d28ad..99b8beef 100644 --- a/src/DefaultBtContext.cc +++ b/src/DefaultBtContext.cc @@ -183,9 +183,22 @@ void DefaultBtContext::extractFileEntries(const bencode::BDE& infoDict, // Slice path by '/' just in case nasty ".." is included in name std::deque<std::string> pathelems; Util::slice(pathelems, name, '/'); + + // For each uri in urlList, if it ends with '/', then + // concatenate name to it. Specification just says so. + std::deque<std::string> uris; + for(std::deque<std::string>::const_iterator i = urlList.begin(); + i != urlList.end(); ++i) { + if(Util::endsWith(*i, "/")) { + uris.push_back((*i)+name); + } else { + uris.push_back(*i); + } + } + SharedHandle<FileEntry> fileEntry (new FileEntry(_dir+"/"+Util::joinPath(pathelems.begin(),pathelems.end()), - totalLength, 0, urlList)); + totalLength, 0, uris)); fileEntries.push_back(fileEntry); } } diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc index 871c0d41..a33d179c 100644 --- a/src/RequestGroup.cc +++ b/src/RequestGroup.cc @@ -226,6 +226,12 @@ void RequestGroup::createInitialCommand(std::deque<Command*>& commands, _uris.clear(); _pieceStorage->setFileFilter(btContext->getFileFilter()); + } else if(btContext->getFileEntries().size() == 1) { + // web-seeding is only enabled for single file torrent + SharedHandle<FileEntry> fileEntry = btContext->getFileEntries().front(); + _uris.insert(_uris.end(), + fileEntry->getAssociatedUris().begin(), + fileEntry->getAssociatedUris().end()); } SharedHandle<DefaultBtProgressInfoFile> |
