FEATURE: If 2 torrents have the same hash, add new trackers to the existin

g torrent
This commit is contained in:
Christophe Dumez 2010-02-07 14:31:45 +00:00
parent 2b37986007
commit 1065f5fb86
2 changed files with 27 additions and 0 deletions

View file

@ -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 <chris@qbittorrent.org> - v2.1.0

View file

@ -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<announce_entry> old_trackers = h.trackers();
std::vector<announce_entry> new_trackers = t->trackers();
bool trackers_added = false;
for(std::vector<announce_entry>::iterator it=new_trackers.begin();it!=new_trackers.end();it++) {
std::string tracker_url = it->url;
bool found = false;
for(std::vector<announce_entry>::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);