mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-21 05:43:32 -07:00
Set metadata asynchronously
This commit is contained in:
parent
991c30943a
commit
998b08f5d8
3 changed files with 14 additions and 7 deletions
|
@ -310,7 +310,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 void setMetadata(const TorrentInfo &torrentInfo) = 0;
|
||||||
|
|
||||||
virtual StopCondition stopCondition() const = 0;
|
virtual StopCondition stopCondition() const = 0;
|
||||||
virtual void setStopCondition(StopCondition stopCondition) = 0;
|
virtual void setStopCondition(StopCondition stopCondition) = 0;
|
||||||
|
|
|
@ -2215,18 +2215,25 @@ lt::torrent_handle TorrentImpl::nativeHandle() const
|
||||||
return m_nativeHandle;
|
return m_nativeHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TorrentImpl::setMetadata(const TorrentInfo &torrentInfo)
|
void TorrentImpl::setMetadata(const TorrentInfo &torrentInfo)
|
||||||
{
|
{
|
||||||
if (hasMetadata())
|
if (hasMetadata())
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
|
m_session->invokeAsync([nativeHandle = m_nativeHandle, torrentInfo]
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
#ifdef QBT_USES_LIBTORRENT2
|
#ifdef QBT_USES_LIBTORRENT2
|
||||||
return m_nativeHandle.set_metadata(torrentInfo.nativeInfo()->info_section());
|
nativeHandle.set_metadata(torrentInfo.nativeInfo()->info_section());
|
||||||
#else
|
#else
|
||||||
const std::shared_ptr<lt::torrent_info> nativeInfo = torrentInfo.nativeInfo();
|
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()));
|
nativeHandle.set_metadata(lt::span<const char>(nativeInfo->metadata().get(), nativeInfo->metadata_size()));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
catch (const std::exception &) {}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Torrent::StopCondition TorrentImpl::stopCondition() const
|
Torrent::StopCondition TorrentImpl::stopCondition() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -227,7 +227,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;
|
void setMetadata(const TorrentInfo &torrentInfo) override;
|
||||||
|
|
||||||
StopCondition stopCondition() const override;
|
StopCondition stopCondition() const override;
|
||||||
void setStopCondition(StopCondition stopCondition) override;
|
void setStopCondition(StopCondition stopCondition) override;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue