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;