Handle some torrent conflicts

PR #17576.
This commit is contained in:
Vladimir Golovnev
2022-08-23 07:47:20 +03:00
committed by GitHub
parent d173216941
commit 7527343629
9 changed files with 188 additions and 60 deletions

View File

@@ -50,6 +50,15 @@ bool BitTorrent::InfoHash::isValid() const
return m_valid;
}
bool BitTorrent::InfoHash::isHybrid() const
{
#ifdef QBT_USES_LIBTORRENT2
return (m_nativeHash.has_v1() && m_nativeHash.has_v2());
#else
return false;
#endif
}
SHA1Hash BitTorrent::InfoHash::v1() const
{
#ifdef QBT_USES_LIBTORRENT2
@@ -84,7 +93,7 @@ BitTorrent::InfoHash::operator WrappedType() const
BitTorrent::TorrentID BitTorrent::TorrentID::fromString(const QString &hashString)
{
return {BaseType::fromString(hashString)};
return TorrentID(BaseType::fromString(hashString));
}
BitTorrent::TorrentID BitTorrent::TorrentID::fromInfoHash(const BitTorrent::InfoHash &infoHash)
@@ -92,6 +101,16 @@ BitTorrent::TorrentID BitTorrent::TorrentID::fromInfoHash(const BitTorrent::Info
return infoHash.toTorrentID();
}
BitTorrent::TorrentID BitTorrent::TorrentID::fromSHA1Hash(const SHA1Hash &hash)
{
return TorrentID(hash);
}
BitTorrent::TorrentID BitTorrent::TorrentID::fromSHA256Hash(const SHA256Hash &hash)
{
return BaseType::UnderlyingType(static_cast<typename SHA256Hash::UnderlyingType>(hash).data());
}
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t BitTorrent::qHash(const BitTorrent::TorrentID &key, const std::size_t seed)
#else