Browse Source

Fix import of new trackers when adding a torrent with same hash (Closes #747000)

adaptive-webui-19844
Christophe Dumez 13 years ago
parent
commit
d53ca1d096
  1. 25
      src/qtlibtorrent/qbtsession.cpp

25
src/qtlibtorrent/qbtsession.cpp

@ -1307,27 +1307,29 @@ void QBtSession::mergeTorrents(QTorrentHandle &h_ex, boost::intrusive_ptr<torren @@ -1307,27 +1307,29 @@ void QBtSession::mergeTorrents(QTorrentHandle &h_ex, boost::intrusive_ptr<torren
// Check if the torrent contains trackers or url seeds we don't know about
// and add them
if(!h_ex.is_valid()) return;
std::vector<announce_entry> old_trackers = h_ex.trackers();
std::vector<announce_entry> existing_trackers = h_ex.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;
foreach (const announce_entry& new_tracker, new_trackers) {
std::string new_tracker_url = new_tracker.url;
// Check if existing torrent has this tracker
bool found = false;
for(std::vector<announce_entry>::iterator itold=old_trackers.begin();itold!=old_trackers.end();itold++) {
if(tracker_url == itold->url) {
foreach (const announce_entry& existing_tracker, existing_trackers) {
if(QUrl(new_tracker_url.c_str()) == QUrl(existing_tracker.url.c_str())) {
found = true;
break;
}
}
if(found) {
if (!found) {
h_ex.add_tracker(announce_entry(new_tracker_url));
trackers_added = true;
announce_entry entry(tracker_url);
h_ex.add_tracker(entry);
}
}
if(trackers_added) {
if (trackers_added)
addConsoleMessage(tr("Note: new trackers were added to the existing torrent."));
}
bool urlseeds_added = false;
const QStringList old_urlseeds = h_ex.url_seeds();
#if LIBTORRENT_VERSION_MINOR > 15
@ -1351,10 +1353,9 @@ void QBtSession::mergeTorrents(QTorrentHandle &h_ex, boost::intrusive_ptr<torren @@ -1351,10 +1353,9 @@ void QBtSession::mergeTorrents(QTorrentHandle &h_ex, boost::intrusive_ptr<torren
}
}
#endif
if(urlseeds_added) {
if(urlseeds_added)
addConsoleMessage(tr("Note: new URL seeds were added to the existing torrent."));
}
}
void QBtSession::exportTorrentFiles(QString path) {
Q_ASSERT(torrentExport);

Loading…
Cancel
Save