From 1065f5fb864cb2824be20349f2047d3f76568fe8 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sun, 7 Feb 2010 14:31:45 +0000 Subject: [PATCH] FEATURE: If 2 torrents have the same hash, add new trackers to the existin g torrent --- Changelog | 1 + src/bittorrent.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/Changelog b/Changelog index c63268c62..c6cce34e1 100644 --- a/Changelog +++ b/Changelog @@ -8,6 +8,7 @@ - FEATURE: User can choose to apply transfer limits on LAN too - FEATURE: User can choose to include the protocol overhead in transfer limits - FEATURE: Torrents can be automatically rechecked on completion + - FEATURE: If 2 torrents have the same hash, add new trackers to the existing torrent - COSMETIC: Improved style management * Mon Jan 18 2010 - Christophe Dumez - v2.1.0 diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index ea5440da7..02308fee4 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -978,6 +978,32 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr addConsoleMessage(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(file)); //emit duplicateTorrent(file); } + // Check if the torrent contains trackers we don't know about + // and add them + QTorrentHandle h_ex = getTorrentHandle(hash); + if(h_ex.is_valid()) { + std::vector old_trackers = h.trackers(); + std::vector new_trackers = t->trackers(); + bool trackers_added = false; + for(std::vector::iterator it=new_trackers.begin();it!=new_trackers.end();it++) { + std::string tracker_url = it->url; + bool found = false; + for(std::vector::iterator itold=old_trackers.begin();itold!=old_trackers.end();itold++) { + if(tracker_url == itold->url) { + found = true; + break; + } + } + if(!found) { + trackers_added = true; + announce_entry entry(tracker_url); + h.add_tracker(entry); + } + } + if(trackers_added) { + addConsoleMessage(tr("However, new trackers were added to the existing torrent.")); + } + } }else{ // Delete torrent from scan dir QFile::remove(file);