WebAPI: Fix looking up hybrid torrent metadata

This commit is contained in:
Thomas Piccirello 2025-06-29 09:32:43 -07:00
commit 672b98f7a0
No known key found for this signature in database

View file

@ -2130,5 +2130,15 @@ void TorrentsController::onMetadataDownloaded(const BitTorrent::TorrentInfo &inf
return; return;
if (auto iter = m_torrentMetadataCache.find(info.infoHash().toTorrentID()); iter != m_torrentMetadataCache.end()) if (auto iter = m_torrentMetadataCache.find(info.infoHash().toTorrentID()); iter != m_torrentMetadataCache.end())
{
iter.value().setTorrentInfo(info); iter.value().setTorrentInfo(info);
}
else if (info.infoHash().isHybrid())
{
// hybrid torrents use the v2 hash for their torrentID, but the torrent may have previously been stored
// in m_torrentMetadataCache using the v1 hash, before the v2 hash was known/available
const BitTorrent::TorrentID v1TorrentID = BitTorrent::TorrentID::fromSHA1Hash(info.infoHash().v1());
if (auto iter = m_torrentMetadataCache.find(v1TorrentID); iter != m_torrentMetadataCache.end())
iter.value().setTorrentInfo(info);
}
} }