mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 07:27:22 -06:00
Improve "info hash" handling
Define "torrent ID" concept, which is either a SHA1 hash for torrents of version 1, or a SHA256 hash (truncated to SHA1 hash length) for torrents of version 2. Add support for native libtorrent2 info hashes.
This commit is contained in:
@@ -218,6 +218,11 @@ TorrentImpl::TorrentImpl(Session *session, lt::session *nativeSession
|
||||
, m_session(session)
|
||||
, m_nativeSession(nativeSession)
|
||||
, m_nativeHandle(nativeHandle)
|
||||
#if (LIBTORRENT_VERSION_NUM >= 20000)
|
||||
, m_infoHash(m_nativeHandle.info_hashes())
|
||||
#else
|
||||
, m_infoHash(m_nativeHandle.info_hash())
|
||||
#endif
|
||||
, m_name(params.name)
|
||||
, m_savePath(Utils::Fs::toNativePath(params.savePath))
|
||||
, m_category(params.category)
|
||||
@@ -235,7 +240,6 @@ TorrentImpl::TorrentImpl(Session *session, lt::session *nativeSession
|
||||
if (m_useAutoTMM)
|
||||
m_savePath = Utils::Fs::toNativePath(m_session->categorySavePath(m_category));
|
||||
|
||||
m_hash = InfoHash {m_nativeHandle.info_hash()};
|
||||
if (m_ltAddTorrentParams.ti)
|
||||
{
|
||||
// Initialize it only if torrent is added with metadata.
|
||||
@@ -280,9 +284,9 @@ bool TorrentImpl::isValid() const
|
||||
return m_nativeHandle.is_valid();
|
||||
}
|
||||
|
||||
InfoHash TorrentImpl::hash() const
|
||||
InfoHash TorrentImpl::infoHash() const
|
||||
{
|
||||
return m_hash;
|
||||
return m_infoHash;
|
||||
}
|
||||
|
||||
QString TorrentImpl::name() const
|
||||
@@ -297,7 +301,7 @@ QString TorrentImpl::name() const
|
||||
if (!name.isEmpty())
|
||||
return name;
|
||||
|
||||
return m_hash.toString();
|
||||
return id().toString();
|
||||
}
|
||||
|
||||
QDateTime TorrentImpl::creationDate() const
|
||||
|
||||
Reference in New Issue
Block a user