From a3e7095f844b14b5456fdf743b37cb4f9a2e4625 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 30 Dec 2010 06:46:28 +0000 Subject: [PATCH] url downloading fix --- include/libtorrent/torrent.hpp | 2 ++ src/session_impl.cpp | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 2df137333..23dca903a 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -699,6 +699,8 @@ namespace libtorrent torrent_info const& torrent_file() const { return *m_torrent_file; } + std::string const& url() const { return m_url; } + std::vector const& trackers() const { return m_trackers; } diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 1f631afcc..579be6838 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -3575,6 +3575,14 @@ namespace aux { session_impl::torrent_map::iterator i = m_torrents.find(tptr->torrent_file().info_hash()); + // this torrent might be filed under the URL-hash + if (i == m_torrents.end() && !tptr->url().empty()) + { + std::string const& url = tptr->url(); + sha1_hash urlhash = hasher(&url[0], url.size()).final(); + i = m_torrents.find(urlhash); + } + if (i != m_torrents.end()) { torrent& t = *i->second;