From 29f8b4b78623ae5e883a7a6d3aa916002d3e9045 Mon Sep 17 00:00:00 2001 From: Vladimir Golovnev Date: Fri, 29 Jul 2022 15:40:40 +0300 Subject: [PATCH] Don't merge trackers by default PR #17446. --- src/base/bittorrent/session.cpp | 27 +-------------------------- src/gui/addnewtorrentdialog.cpp | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 33 deletions(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 36dc11a5d..36f536815 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -2502,32 +2502,7 @@ bool Session::addTorrent_impl(const std::variant &source TorrentImpl *const torrent = m_torrents.value(id); if (torrent) - { // a duplicate torrent is added - if (torrent->isPrivate()) - return false; - - if (hasMetadata) - { - const TorrentInfo &torrentInfo = std::get(source); - - if (torrentInfo.isPrivate()) - return false; - - // merge trackers and web seeds - torrent->addTrackers(torrentInfo.trackers()); - torrent->addUrlSeeds(torrentInfo.urlSeeds()); - } - else - { - const MagnetUri &magnetUri = std::get(source); - - // merge trackers and web seeds - torrent->addTrackers(magnetUri.trackers()); - torrent->addUrlSeeds(magnetUri.urlSeeds()); - } - - return true; - } + return false; LoadTorrentParams loadTorrentParams = initLoadTorrentParams(addTorrentParams); lt::add_torrent_params &p = loadTorrentParams.ltAddTorrentParams; diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index 5d682e28a..66dabb1c7 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -437,19 +437,25 @@ bool AddNewTorrentDialog::loadTorrentImpl() { if (torrent->isPrivate() || m_torrentInfo.isPrivate()) { - RaisedMessageBox::warning(this, tr("Torrent is already present"), tr("Torrent '%1' is already in the transfer list. Trackers haven't been merged because it is a private torrent.").arg(torrent->name()), QMessageBox::Ok); + RaisedMessageBox::warning(this, tr("Torrent is already present"), tr("Torrent '%1' is already in the transfer list. Trackers cannot be merged because it is a private torrent.").arg(torrent->name()), QMessageBox::Ok); } else { - torrent->addTrackers(m_torrentInfo.trackers()); - torrent->addUrlSeeds(m_torrentInfo.urlSeeds()); - RaisedMessageBox::information(this, tr("Torrent is already present"), tr("Torrent '%1' is already in the transfer list. Trackers have been merged.").arg(torrent->name()), QMessageBox::Ok); + const QMessageBox::StandardButton btn = RaisedMessageBox::question(this, tr("Torrent is already present") + , tr("Torrent '%1' is already in the transfer list. Do you want to merge trackers from new source?").arg(torrent->name()) + , (QMessageBox::Yes | QMessageBox::No), QMessageBox::Yes); + if (btn == QMessageBox::Yes) + { + torrent->addTrackers(m_torrentInfo.trackers()); + torrent->addUrlSeeds(m_torrentInfo.urlSeeds()); + } } } else { RaisedMessageBox::information(this, tr("Torrent is already present"), tr("Torrent is already queued for processing."), QMessageBox::Ok); } + return false; } @@ -484,15 +490,21 @@ bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri) } else { - torrent->addTrackers(magnetUri.trackers()); - torrent->addUrlSeeds(magnetUri.urlSeeds()); - RaisedMessageBox::information(this, tr("Torrent is already present"), tr("Magnet link '%1' is already in the transfer list. Trackers have been merged.").arg(torrent->name()), QMessageBox::Ok); + const QMessageBox::StandardButton btn = RaisedMessageBox::question(this, tr("Torrent is already present") + , tr("Torrent '%1' is already in the transfer list. Do you want to merge trackers from new source?").arg(torrent->name()) + , (QMessageBox::Yes | QMessageBox::No), QMessageBox::Yes); + if (btn == QMessageBox::Yes) + { + torrent->addTrackers(magnetUri.trackers()); + torrent->addUrlSeeds(magnetUri.urlSeeds()); + } } } else { RaisedMessageBox::information(this, tr("Torrent is already present"), tr("Magnet link is already queued for processing."), QMessageBox::Ok); } + return false; }