Browse Source

Don't merge trackers for private torrents. Closes #2928.

adaptive-webui-19844
sledgehammer999 9 years ago
parent
commit
b099a766e6
  1. 2
      src/base/bittorrent/session.cpp
  2. 10
      src/gui/addnewtorrentdialog.cpp

2
src/base/bittorrent/session.cpp

@ -1046,6 +1046,8 @@ bool Session::addTorrent_impl(AddTorrentData addData, const MagnetUri &magnetUri @@ -1046,6 +1046,8 @@ bool Session::addTorrent_impl(AddTorrentData addData, const MagnetUri &magnetUri
if (m_torrents.contains(hash)) {
TorrentHandle *const torrent = m_torrents.value(hash);
if (torrent->isPrivate() || (!fromMagnetUri && torrentInfo.isPrivate()))
return false;
torrent->addTrackers(fromMagnetUri ? magnetUri.trackers() : torrentInfo.trackers());
torrent->addUrlSeeds(fromMagnetUri ? magnetUri.urlSeeds() : torrentInfo.urlSeeds());
return true;

10
src/gui/addnewtorrentdialog.cpp

@ -189,10 +189,15 @@ bool AddNewTorrentDialog::loadTorrent(const QString &torrentPath) @@ -189,10 +189,15 @@ bool AddNewTorrentDialog::loadTorrent(const QString &torrentPath)
if (BitTorrent::Session::instance()->isKnownTorrent(m_hash)) {
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(m_hash);
if (torrent) {
if (torrent->isPrivate() || m_torrentInfo.isPrivate()) {
MessageBoxRaised::critical(0, tr("Already in download list"), tr("Torrent is already in download list. Trackers weren't merged because it is a private torrent."), QMessageBox::Ok);
}
else {
torrent->addTrackers(m_torrentInfo.trackers());
torrent->addUrlSeeds(m_torrentInfo.urlSeeds());
MessageBoxRaised::information(0, tr("Already in download list"), tr("Torrent is already in download list. Trackers were merged."), QMessageBox::Ok);
}
}
else {
MessageBoxRaised::critical(0, tr("Cannot add torrent"), tr("Cannot add this torrent. Perhaps it is already in adding state."), QMessageBox::Ok);
}
@ -216,10 +221,15 @@ bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri) @@ -216,10 +221,15 @@ bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri)
if (BitTorrent::Session::instance()->isKnownTorrent(m_hash)) {
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(m_hash);
if (torrent) {
if (torrent->isPrivate()) {
MessageBoxRaised::critical(0, tr("Already in download list"), tr("Torrent is already in download list. Trackers weren't merged because it is a private torrent."), QMessageBox::Ok);
}
else {
torrent->addTrackers(magnetUri.trackers());
torrent->addUrlSeeds(magnetUri.urlSeeds());
MessageBoxRaised::information(0, tr("Already in download list"), tr("Magnet link is already in download list. Trackers were merged."), QMessageBox::Ok);
}
}
else {
MessageBoxRaised::critical(0, tr("Cannot add torrent"), tr("Cannot add this torrent. Perhaps it is already in adding."), QMessageBox::Ok);
}

Loading…
Cancel
Save