Browse Source

Always honor the configured behavior for merging trackers

PR #19305.

* Always honor the configured behavior for merging trackers
* Clarify merging trackers related options
adaptive-webui-19844
Vladimir Golovnev 1 year ago committed by GitHub
parent
commit
7b4b7c2b81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      src/base/bittorrent/sessionimpl.cpp
  2. 11
      src/gui/optionsdialog.cpp
  3. 8
      src/gui/optionsdialog.ui

10
src/base/bittorrent/sessionimpl.cpp

@ -2747,10 +2747,16 @@ bool SessionImpl::addTorrent_impl(const std::variant<MagnetUri, TorrentInfo> &so
torrent->setMetadata(std::get<TorrentInfo>(source)); torrent->setMetadata(std::get<TorrentInfo>(source));
} }
if (!isMergeTrackersEnabled())
{
LogMsg(tr("Detected an attempt to add a duplicate torrent. Merging of trackers is disabled. Torrent: %1").arg(torrent->name()));
return false;
}
const bool isPrivate = torrent->isPrivate() || (hasMetadata && std::get<TorrentInfo>(source).isPrivate()); const bool isPrivate = torrent->isPrivate() || (hasMetadata && std::get<TorrentInfo>(source).isPrivate());
if (isPrivate) if (isPrivate)
{ {
LogMsg(tr("Found existing torrent. Trackers cannot be merged because it is a private torrent. Torrent: %1").arg(torrent->name())); LogMsg(tr("Detected an attempt to add a duplicate torrent. Trackers cannot be merged because it is a private torrent. Torrent: %1").arg(torrent->name()));
return false; return false;
} }
@ -2771,7 +2777,7 @@ bool SessionImpl::addTorrent_impl(const std::variant<MagnetUri, TorrentInfo> &so
torrent->addUrlSeeds(magnetUri.urlSeeds()); torrent->addUrlSeeds(magnetUri.urlSeeds());
} }
LogMsg(tr("Found existing torrent. Trackers are merged from new source. Torrent: %1").arg(torrent->name())); LogMsg(tr("Detected an attempt to add a duplicate torrent. Trackers are merged from new source. Torrent: %1").arg(torrent->name()));
return false; return false;
} }

11
src/gui/optionsdialog.cpp

@ -505,7 +505,13 @@ void OptionsDialog::loadDownloadsTabOptions()
m_ui->stopConditionComboBox->setEnabled(!m_ui->checkStartPaused->isChecked()); m_ui->stopConditionComboBox->setEnabled(!m_ui->checkStartPaused->isChecked());
m_ui->checkMergeTrackers->setChecked(session->isMergeTrackersEnabled()); m_ui->checkMergeTrackers->setChecked(session->isMergeTrackersEnabled());
m_ui->checkConfirmMergeTrackers->setChecked(pref->confirmMergeTrackers()); m_ui->checkConfirmMergeTrackers->setEnabled(m_ui->checkAdditionDialog->isChecked());
m_ui->checkConfirmMergeTrackers->setChecked(m_ui->checkConfirmMergeTrackers->isEnabled() ? pref->confirmMergeTrackers() : false);
connect(m_ui->checkAdditionDialog, &QGroupBox::toggled, this, [this, pref]
{
m_ui->checkConfirmMergeTrackers->setEnabled(m_ui->checkAdditionDialog->isChecked());
m_ui->checkConfirmMergeTrackers->setChecked(m_ui->checkConfirmMergeTrackers->isEnabled() ? pref->confirmMergeTrackers() : false);
});
const TorrentFileGuard::AutoDeleteMode autoDeleteMode = TorrentFileGuard::autoDeleteMode(); const TorrentFileGuard::AutoDeleteMode autoDeleteMode = TorrentFileGuard::autoDeleteMode();
m_ui->deleteTorrentBox->setChecked(autoDeleteMode != TorrentFileGuard::Never); m_ui->deleteTorrentBox->setChecked(autoDeleteMode != TorrentFileGuard::Never);
@ -692,7 +698,8 @@ void OptionsDialog::saveDownloadsTabOptions() const
: !m_ui->deleteCancelledTorrentBox->isChecked() ? TorrentFileGuard::IfAdded : !m_ui->deleteCancelledTorrentBox->isChecked() ? TorrentFileGuard::IfAdded
: TorrentFileGuard::Always); : TorrentFileGuard::Always);
session->setMergeTrackersEnabled(m_ui->checkMergeTrackers->isChecked()); session->setMergeTrackersEnabled(m_ui->checkMergeTrackers->isChecked());
pref->setConfirmMergeTrackers(m_ui->checkConfirmMergeTrackers->isChecked()); if (m_ui->checkConfirmMergeTrackers->isEnabled())
pref->setConfirmMergeTrackers(m_ui->checkConfirmMergeTrackers->isChecked());
session->setPreallocationEnabled(preAllocateAllFiles()); session->setPreallocationEnabled(preAllocateAllFiles());
session->setAppendExtensionEnabled(m_ui->checkAppendqB->isChecked()); session->setAppendExtensionEnabled(m_ui->checkAppendqB->isChecked());

8
src/gui/optionsdialog.ui

@ -958,9 +958,6 @@
<layout class="QVBoxLayout" name="duplicateTorrentBoxLayout"> <layout class="QVBoxLayout" name="duplicateTorrentBoxLayout">
<item> <item>
<widget class="QCheckBox" name="checkMergeTrackers"> <widget class="QCheckBox" name="checkMergeTrackers">
<property name="toolTip">
<string>Whether trackers should be merged to existing torrent</string>
</property>
<property name="text"> <property name="text">
<string>Merge trackers to existing torrent</string> <string>Merge trackers to existing torrent</string>
</property> </property>
@ -971,11 +968,8 @@
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkConfirmMergeTrackers"> <widget class="QCheckBox" name="checkConfirmMergeTrackers">
<property name="toolTip">
<string>Shows a confirmation dialog upon merging trackers to existing torrent</string>
</property>
<property name="text"> <property name="text">
<string>Confirm merging trackers</string> <string>Ask for merging trackers when torrent is being added manually</string>
</property> </property>
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>true</bool>

Loading…
Cancel
Save