mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
Store and use full magnet URI instead of hash
This commit is contained in:
parent
20206ec92a
commit
5727fcb001
2 changed files with 17 additions and 14 deletions
|
@ -39,6 +39,7 @@
|
|||
#include <QVector>
|
||||
|
||||
#include "base/bittorrent/downloadpriority.h"
|
||||
#include "base/bittorrent/infohash.h"
|
||||
#include "base/bittorrent/magneturi.h"
|
||||
#include "base/bittorrent/session.h"
|
||||
#include "base/bittorrent/torrenthandle.h"
|
||||
|
@ -276,11 +277,11 @@ bool AddNewTorrentDialog::loadTorrentFile(const QString &torrentPath)
|
|||
bool AddNewTorrentDialog::loadTorrentImpl()
|
||||
{
|
||||
m_hasMetadata = true;
|
||||
m_hash = m_torrentInfo.hash();
|
||||
const BitTorrent::InfoHash infoHash = m_torrentInfo.hash();
|
||||
|
||||
// Prevent showing the dialog if download is already present
|
||||
if (BitTorrent::Session::instance()->isKnownTorrent(m_hash)) {
|
||||
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(m_hash);
|
||||
if (BitTorrent::Session::instance()->isKnownTorrent(infoHash)) {
|
||||
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(infoHash);
|
||||
if (torrent) {
|
||||
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);
|
||||
|
@ -297,7 +298,7 @@ bool AddNewTorrentDialog::loadTorrentImpl()
|
|||
return false;
|
||||
}
|
||||
|
||||
m_ui->labelHashData->setText(m_hash);
|
||||
m_ui->labelHashData->setText(infoHash);
|
||||
setupTreeview();
|
||||
TMMChanged(m_ui->comboTTM->currentIndex());
|
||||
m_ui->keepTopLevelFolderCheckBox->setEnabled(m_torrentInfo.hasRootFolder());
|
||||
|
@ -312,10 +313,11 @@ bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri)
|
|||
}
|
||||
|
||||
m_torrentGuard = std::make_unique<TorrentFileGuard>();
|
||||
m_hash = magnetUri.hash();
|
||||
|
||||
const BitTorrent::InfoHash infoHash = magnetUri.hash();
|
||||
// Prevent showing the dialog if download is already present
|
||||
if (BitTorrent::Session::instance()->isKnownTorrent(m_hash)) {
|
||||
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(m_hash);
|
||||
if (BitTorrent::Session::instance()->isKnownTorrent(infoHash)) {
|
||||
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(infoHash);
|
||||
if (torrent) {
|
||||
if (torrent->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);
|
||||
|
@ -335,7 +337,7 @@ bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri)
|
|||
connect(BitTorrent::Session::instance(), &BitTorrent::Session::metadataLoaded, this, &AddNewTorrentDialog::updateMetadata);
|
||||
|
||||
// Set dialog title
|
||||
QString torrentName = magnetUri.name();
|
||||
const QString torrentName = magnetUri.name();
|
||||
setWindowTitle(torrentName.isEmpty() ? tr("Magnet link") : torrentName);
|
||||
|
||||
setupTreeview();
|
||||
|
@ -343,8 +345,9 @@ bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri)
|
|||
|
||||
BitTorrent::Session::instance()->loadMetadata(magnetUri);
|
||||
setMetadataProgressIndicator(true, tr("Retrieving metadata..."));
|
||||
m_ui->labelHashData->setText(m_hash);
|
||||
m_ui->labelHashData->setText(infoHash);
|
||||
|
||||
m_magnetURI = magnetUri;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -573,7 +576,7 @@ void AddNewTorrentDialog::accept()
|
|||
|
||||
// Add torrent
|
||||
if (!m_hasMetadata)
|
||||
BitTorrent::Session::instance()->addTorrent(m_hash, m_torrentParams);
|
||||
BitTorrent::Session::instance()->addTorrent(m_magnetURI, m_torrentParams);
|
||||
else
|
||||
BitTorrent::Session::instance()->addTorrent(m_torrentInfo, m_torrentParams);
|
||||
|
||||
|
@ -585,7 +588,7 @@ void AddNewTorrentDialog::reject()
|
|||
{
|
||||
if (!m_hasMetadata) {
|
||||
setMetadataProgressIndicator(false);
|
||||
BitTorrent::Session::instance()->cancelLoadMetadata(m_hash);
|
||||
BitTorrent::Session::instance()->cancelLoadMetadata(m_magnetURI.hash());
|
||||
}
|
||||
|
||||
QDialog::reject();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue