From 3d6145f713e46b2ab977e1b67e47685cc2b90a3a Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 15 Sep 2013 12:29:09 +0000 Subject: [PATCH] resolve duplicate torrents by URL as well (by linear scan) --- src/session_impl.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/session_impl.cpp b/src/session_impl.cpp index b7adc7fb0..8be95bcc0 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -5287,7 +5287,15 @@ retry: // is the torrent already active? boost::shared_ptr torrent_ptr = find_torrent(*ih).lock(); if (!torrent_ptr && !params.uuid.empty()) torrent_ptr = find_torrent(params.uuid).lock(); - // TODO: 2 if we still can't find the torrent, we should probably look for it by url here + // if we still can't find the torrent, look for it by url + if (!torrent_ptr && !params.url.empty()) + { + std::map >::iterator i = std::find_if(m_torrents.begin() + , m_torrents.end(), boost::bind(&torrent::url, boost::bind(&std::pair >::second, _1)) == params.url); + if (i != m_torrents.end()) + torrent_ptr = i->second; + } if (torrent_ptr) {