mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-24 05:25:37 +00:00
When duplicate torrent is added set metadata to existing one
PR #17454. Closes #907.
This commit is contained in:
parent
748226be29
commit
1c0479a795
@ -2502,7 +2502,15 @@ bool Session::addTorrent_impl(const std::variant<MagnetUri, TorrentInfo> &source
|
|||||||
|
|
||||||
TorrentImpl *const torrent = m_torrents.value(id);
|
TorrentImpl *const torrent = m_torrents.value(id);
|
||||||
if (torrent)
|
if (torrent)
|
||||||
|
{
|
||||||
|
if (hasMetadata)
|
||||||
|
{
|
||||||
|
// Trying to set metadata to existing torrent in case if it has none
|
||||||
|
torrent->setMetadata(std::get<TorrentInfo>(source));
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
LoadTorrentParams loadTorrentParams = initLoadTorrentParams(addTorrentParams);
|
LoadTorrentParams loadTorrentParams = initLoadTorrentParams(addTorrentParams);
|
||||||
lt::add_torrent_params &p = loadTorrentParams.ltAddTorrentParams;
|
lt::add_torrent_params &p = loadTorrentParams.ltAddTorrentParams;
|
||||||
|
@ -298,6 +298,7 @@ namespace BitTorrent
|
|||||||
virtual void removeUrlSeeds(const QVector<QUrl> &urlSeeds) = 0;
|
virtual void removeUrlSeeds(const QVector<QUrl> &urlSeeds) = 0;
|
||||||
virtual bool connectPeer(const PeerAddress &peerAddress) = 0;
|
virtual bool connectPeer(const PeerAddress &peerAddress) = 0;
|
||||||
virtual void clearPeers() = 0;
|
virtual void clearPeers() = 0;
|
||||||
|
virtual bool setMetadata(const TorrentInfo &torrentInfo) = 0;
|
||||||
|
|
||||||
virtual QString createMagnetURI() const = 0;
|
virtual QString createMagnetURI() const = 0;
|
||||||
virtual nonstd::expected<QByteArray, QString> exportToBuffer() const = 0;
|
virtual nonstd::expected<QByteArray, QString> exportToBuffer() const = 0;
|
||||||
|
@ -2126,6 +2126,19 @@ lt::torrent_handle TorrentImpl::nativeHandle() const
|
|||||||
return m_nativeHandle;
|
return m_nativeHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TorrentImpl::setMetadata(const TorrentInfo &torrentInfo)
|
||||||
|
{
|
||||||
|
if (hasMetadata())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#ifdef QBT_USES_LIBTORRENT2
|
||||||
|
return m_nativeHandle.set_metadata(torrentInfo.nativeInfo()->info_section());
|
||||||
|
#else
|
||||||
|
const std::shared_ptr<lt::torrent_info> nativeInfo = torrentInfo.nativeInfo();
|
||||||
|
return m_nativeHandle.set_metadata(lt::span<const char>(nativeInfo->metadata().get(), nativeInfo->metadata_size()));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
bool TorrentImpl::isMoveInProgress() const
|
bool TorrentImpl::isMoveInProgress() const
|
||||||
{
|
{
|
||||||
return m_storageIsMoving;
|
return m_storageIsMoving;
|
||||||
|
@ -225,6 +225,7 @@ namespace BitTorrent
|
|||||||
void removeUrlSeeds(const QVector<QUrl> &urlSeeds) override;
|
void removeUrlSeeds(const QVector<QUrl> &urlSeeds) override;
|
||||||
bool connectPeer(const PeerAddress &peerAddress) override;
|
bool connectPeer(const PeerAddress &peerAddress) override;
|
||||||
void clearPeers() override;
|
void clearPeers() override;
|
||||||
|
bool setMetadata(const TorrentInfo &torrentInfo) override;
|
||||||
|
|
||||||
QString createMagnetURI() const override;
|
QString createMagnetURI() const override;
|
||||||
nonstd::expected<QByteArray, QString> exportToBuffer() const override;
|
nonstd::expected<QByteArray, QString> exportToBuffer() const override;
|
||||||
|
@ -435,6 +435,9 @@ bool AddNewTorrentDialog::loadTorrentImpl()
|
|||||||
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(torrentID);
|
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(torrentID);
|
||||||
if (torrent)
|
if (torrent)
|
||||||
{
|
{
|
||||||
|
// Trying to set metadata to existing torrent in case if it has none
|
||||||
|
torrent->setMetadata(m_torrentInfo);
|
||||||
|
|
||||||
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 cannot be 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 cannot be merged because it is a private torrent.").arg(torrent->name()), QMessageBox::Ok);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user