diff --git a/ChangeLog b/ChangeLog index 5ec7eb75..057e8601 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-07-01 Tatsuhiro Tsujikawa + + Don't append "/" if base URI ends with "/". + * src/bittorrent_helper.cc + * test/url-list-multiFile.torrent + 2009-07-01 Tatsuhiro Tsujikawa HTTP pipelining is now working. Fixed Segmention fault in diff --git a/src/bittorrent_helper.cc b/src/bittorrent_helper.cc index b21d9cc8..698a4e7b 100644 --- a/src/bittorrent_helper.cc +++ b/src/bittorrent_helper.cc @@ -134,6 +134,21 @@ static void extractUrlList(std::vector& uris, const BDE& bde) } } +template +static OutputIterator createUri +(InputIterator first, InputIterator last, OutputIterator out, + const std::string& filePath) +{ + for(; first != last; ++first) { + if(Util::endsWith(*first, "/")) { + *out++ = (*first)+filePath; + } else { + *out++ = (*first)+"/"+filePath; + } + } + return out; +} + static void extractFileEntries (const SharedHandle& ctx, BDE& torrent, @@ -209,8 +224,7 @@ static void extractFileEntries path = Util::joinPath(elements.begin(), elements.end()); std::deque uris; - std::transform(urlList.begin(), urlList.end(), std::back_inserter(uris), - std::bind2nd(std::plus(), "/"+path)); + createUri(urlList.begin(), urlList.end(), std::back_inserter(uris), path); SharedHandle fileEntry (new FileEntry(strconcat(ctx->getDir(), "/", path), fileLengthData.i(), diff --git a/test/url-list-multiFile.torrent b/test/url-list-multiFile.torrent index a4888f06..5f7af667 100644 --- a/test/url-list-multiFile.torrent +++ b/test/url-list-multiFile.torrent @@ -1 +1 @@ -d8:url-listl21:http://localhost/dist18:http://mirror/diste8:announce36:http://aria.rednoah.com/announce.php13:announce-listll15:http://tracker1el15:http://tracker2el15:http://tracker3ee7:comment17:REDNOAH.COM RULES13:creation datei1123456789e4:infod5:filesld6:lengthi284e4:pathl5:aria23:src6:aria2ceed6:lengthi100e4:pathl19:aria2-0.2.2.tar.bz2eee4:name10:aria2-test12:piece lengthi128e6:pieces60:AAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCee \ No newline at end of file +d8:url-listl22:http://localhost/dist/18:http://mirror/diste8:announce36:http://aria.rednoah.com/announce.php13:announce-listll15:http://tracker1el15:http://tracker2el15:http://tracker3ee7:comment17:REDNOAH.COM RULES13:creation datei1123456789e4:infod5:filesld6:lengthi284e4:pathl5:aria23:src6:aria2ceed6:lengthi100e4:pathl19:aria2-0.2.2.tar.bz2eee4:name10:aria2-test12:piece lengthi128e6:pieces60:AAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCee \ No newline at end of file