Skip to content

Commit

Permalink
Always notify user about duplicate torrent
Browse files Browse the repository at this point in the history
  • Loading branch information
glassez committed Oct 3, 2024
1 parent b5b34c9 commit 1f140f5
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions src/gui/guiaddtorrentmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,26 +189,37 @@ bool GUIAddTorrentManager::processTorrent(const QString &source, const BitTorren
torrent->setMetadata(*torrentDescr.info());
}

if (torrent->isPrivate() || (hasMetadata && torrentDescr.info()->isPrivate()))
const bool isPrivate = torrent->isPrivate() || (hasMetadata && torrentDescr.info()->isPrivate());
const bool showConfirmDialog = !isPrivate && Preferences::instance()->confirmMergeTrackers();
bool mergeTrackers = btSession()->isMergeTrackersEnabled();
if (showConfirmDialog)
{
handleDuplicateTorrent(source, torrent, tr("Trackers cannot be merged because it is a private torrent"));
const QMessageBox::StandardButton btn = RaisedMessageBox::question(app()->mainWindow(), 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);
mergeTrackers = (btn == QMessageBox::Yes);
}
else

if (mergeTrackers && !isPrivate)
{
bool mergeTrackers = btSession()->isMergeTrackersEnabled();
if (Preferences::instance()->confirmMergeTrackers())
{
const QMessageBox::StandardButton btn = RaisedMessageBox::question(app()->mainWindow(), 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);
mergeTrackers = (btn == QMessageBox::Yes);
}
torrent->addTrackers(torrentDescr.trackers());
torrent->addUrlSeeds(torrentDescr.urlSeeds());
}

// We should notify the user about a duplicate torrent, but we do not do this
// if we have already shown a confirmation dialog for merging trackers.
if (!showConfirmDialog)
{
QString message = tr("Torrent '%1' is already in the transfer list.").arg(torrent->name());
if (mergeTrackers)
{
torrent->addTrackers(torrentDescr.trackers());
torrent->addUrlSeeds(torrentDescr.urlSeeds());
if (isPrivate)
message += u" " + tr("Trackers cannot be merged because it is a private torrent.");
else
message += u" " + tr("Trackers merged from new source.");
}

RaisedMessageBox::warning(app()->mainWindow(), tr("Torrent is already present"), message);
}

return false;
Expand Down

0 comments on commit 1f140f5

Please sign in to comment.