When duplicate torrent is added set metadata to existing one

PR #17454. 
Closes #907.
This commit is contained in:
Vladimir Golovnev
2022-07-31 08:53:26 +03:00
committed by GitHub
parent 748226be29
commit 1c0479a795
5 changed files with 26 additions and 0 deletions

View File

@@ -2126,6 +2126,19 @@ lt::torrent_handle TorrentImpl::nativeHandle() const
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
{
return m_storageIsMoving;