mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-03-10 12:21:12 +00:00
Store and use full magnet URI instead of hash
This commit is contained in:
parent
20206ec92a
commit
5727fcb001
@ -39,6 +39,7 @@
|
|||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
#include "base/bittorrent/downloadpriority.h"
|
#include "base/bittorrent/downloadpriority.h"
|
||||||
|
#include "base/bittorrent/infohash.h"
|
||||||
#include "base/bittorrent/magneturi.h"
|
#include "base/bittorrent/magneturi.h"
|
||||||
#include "base/bittorrent/session.h"
|
#include "base/bittorrent/session.h"
|
||||||
#include "base/bittorrent/torrenthandle.h"
|
#include "base/bittorrent/torrenthandle.h"
|
||||||
@ -276,11 +277,11 @@ bool AddNewTorrentDialog::loadTorrentFile(const QString &torrentPath)
|
|||||||
bool AddNewTorrentDialog::loadTorrentImpl()
|
bool AddNewTorrentDialog::loadTorrentImpl()
|
||||||
{
|
{
|
||||||
m_hasMetadata = true;
|
m_hasMetadata = true;
|
||||||
m_hash = m_torrentInfo.hash();
|
const BitTorrent::InfoHash infoHash = m_torrentInfo.hash();
|
||||||
|
|
||||||
// Prevent showing the dialog if download is already present
|
// Prevent showing the dialog if download is already present
|
||||||
if (BitTorrent::Session::instance()->isKnownTorrent(m_hash)) {
|
if (BitTorrent::Session::instance()->isKnownTorrent(infoHash)) {
|
||||||
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(m_hash);
|
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(infoHash);
|
||||||
if (torrent) {
|
if (torrent) {
|
||||||
if (torrent->isPrivate() || m_torrentInfo.isPrivate()) {
|
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);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ui->labelHashData->setText(m_hash);
|
m_ui->labelHashData->setText(infoHash);
|
||||||
setupTreeview();
|
setupTreeview();
|
||||||
TMMChanged(m_ui->comboTTM->currentIndex());
|
TMMChanged(m_ui->comboTTM->currentIndex());
|
||||||
m_ui->keepTopLevelFolderCheckBox->setEnabled(m_torrentInfo.hasRootFolder());
|
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_torrentGuard = std::make_unique<TorrentFileGuard>();
|
||||||
m_hash = magnetUri.hash();
|
|
||||||
|
const BitTorrent::InfoHash infoHash = magnetUri.hash();
|
||||||
// Prevent showing the dialog if download is already present
|
// Prevent showing the dialog if download is already present
|
||||||
if (BitTorrent::Session::instance()->isKnownTorrent(m_hash)) {
|
if (BitTorrent::Session::instance()->isKnownTorrent(infoHash)) {
|
||||||
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(m_hash);
|
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(infoHash);
|
||||||
if (torrent) {
|
if (torrent) {
|
||||||
if (torrent->isPrivate()) {
|
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);
|
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);
|
connect(BitTorrent::Session::instance(), &BitTorrent::Session::metadataLoaded, this, &AddNewTorrentDialog::updateMetadata);
|
||||||
|
|
||||||
// Set dialog title
|
// Set dialog title
|
||||||
QString torrentName = magnetUri.name();
|
const QString torrentName = magnetUri.name();
|
||||||
setWindowTitle(torrentName.isEmpty() ? tr("Magnet link") : torrentName);
|
setWindowTitle(torrentName.isEmpty() ? tr("Magnet link") : torrentName);
|
||||||
|
|
||||||
setupTreeview();
|
setupTreeview();
|
||||||
@ -343,8 +345,9 @@ bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri)
|
|||||||
|
|
||||||
BitTorrent::Session::instance()->loadMetadata(magnetUri);
|
BitTorrent::Session::instance()->loadMetadata(magnetUri);
|
||||||
setMetadataProgressIndicator(true, tr("Retrieving metadata..."));
|
setMetadataProgressIndicator(true, tr("Retrieving metadata..."));
|
||||||
m_ui->labelHashData->setText(m_hash);
|
m_ui->labelHashData->setText(infoHash);
|
||||||
|
|
||||||
|
m_magnetURI = magnetUri;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -573,7 +576,7 @@ void AddNewTorrentDialog::accept()
|
|||||||
|
|
||||||
// Add torrent
|
// Add torrent
|
||||||
if (!m_hasMetadata)
|
if (!m_hasMetadata)
|
||||||
BitTorrent::Session::instance()->addTorrent(m_hash, m_torrentParams);
|
BitTorrent::Session::instance()->addTorrent(m_magnetURI, m_torrentParams);
|
||||||
else
|
else
|
||||||
BitTorrent::Session::instance()->addTorrent(m_torrentInfo, m_torrentParams);
|
BitTorrent::Session::instance()->addTorrent(m_torrentInfo, m_torrentParams);
|
||||||
|
|
||||||
@ -585,7 +588,7 @@ void AddNewTorrentDialog::reject()
|
|||||||
{
|
{
|
||||||
if (!m_hasMetadata) {
|
if (!m_hasMetadata) {
|
||||||
setMetadataProgressIndicator(false);
|
setMetadataProgressIndicator(false);
|
||||||
BitTorrent::Session::instance()->cancelLoadMetadata(m_hash);
|
BitTorrent::Session::instance()->cancelLoadMetadata(m_magnetURI.hash());
|
||||||
}
|
}
|
||||||
|
|
||||||
QDialog::reject();
|
QDialog::reject();
|
||||||
|
@ -34,13 +34,13 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
#include "base/bittorrent/addtorrentparams.h"
|
#include "base/bittorrent/addtorrentparams.h"
|
||||||
#include "base/bittorrent/infohash.h"
|
#include "base/bittorrent/magneturi.h"
|
||||||
#include "base/bittorrent/torrentinfo.h"
|
#include "base/bittorrent/torrentinfo.h"
|
||||||
#include "base/settingvalue.h"
|
#include "base/settingvalue.h"
|
||||||
|
|
||||||
namespace BitTorrent
|
namespace BitTorrent
|
||||||
{
|
{
|
||||||
class MagnetUri;
|
class InfoHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Net
|
namespace Net
|
||||||
@ -112,7 +112,7 @@ private:
|
|||||||
TorrentContentFilterModel *m_contentModel;
|
TorrentContentFilterModel *m_contentModel;
|
||||||
PropListDelegate *m_contentDelegate;
|
PropListDelegate *m_contentDelegate;
|
||||||
bool m_hasMetadata;
|
bool m_hasMetadata;
|
||||||
BitTorrent::InfoHash m_hash;
|
BitTorrent::MagnetUri m_magnetURI;
|
||||||
BitTorrent::TorrentInfo m_torrentInfo;
|
BitTorrent::TorrentInfo m_torrentInfo;
|
||||||
QByteArray m_headerState;
|
QByteArray m_headerState;
|
||||||
int m_oldIndex;
|
int m_oldIndex;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user