Handle some torrent conflicts

PR #17576.
This commit is contained in:
Vladimir Golovnev 2022-08-23 07:47:20 +03:00 committed by GitHub
commit 7527343629
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 188 additions and 60 deletions

View file

@ -427,12 +427,12 @@ bool AddNewTorrentDialog::loadTorrentFile(const QString &source)
bool AddNewTorrentDialog::loadTorrentImpl()
{
const auto torrentID = BitTorrent::TorrentID::fromInfoHash(m_torrentInfo.infoHash());
const BitTorrent::InfoHash infoHash = m_torrentInfo.infoHash();
// Prevent showing the dialog if download is already present
if (BitTorrent::Session::instance()->isKnownTorrent(torrentID))
if (BitTorrent::Session::instance()->isKnownTorrent(infoHash))
{
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(torrentID);
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(infoHash);
if (torrent)
{
// Trying to set metadata to existing torrent in case if it has none
@ -480,11 +480,12 @@ bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri)
m_torrentGuard = std::make_unique<TorrentFileGuard>();
const auto torrentID = BitTorrent::TorrentID::fromInfoHash(magnetUri.infoHash());
const BitTorrent::InfoHash infoHash = magnetUri.infoHash();
// Prevent showing the dialog if download is already present
if (BitTorrent::Session::instance()->isKnownTorrent(torrentID))
if (BitTorrent::Session::instance()->isKnownTorrent(infoHash))
{
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(torrentID);
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(infoHash);
if (torrent)
{
if (torrent->isPrivate())