From 672b98f7a0f752330df3ab32b0a005d73e0fba82 Mon Sep 17 00:00:00 2001 From: Thomas Piccirello Date: Sun, 29 Jun 2025 09:32:43 -0700 Subject: [PATCH] WebAPI: Fix looking up hybrid torrent metadata --- src/webui/api/torrentscontroller.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp index a3acb061d..ce9da3247 100644 --- a/src/webui/api/torrentscontroller.cpp +++ b/src/webui/api/torrentscontroller.cpp @@ -2130,5 +2130,15 @@ void TorrentsController::onMetadataDownloaded(const BitTorrent::TorrentInfo &inf return; if (auto iter = m_torrentMetadataCache.find(info.infoHash().toTorrentID()); iter != m_torrentMetadataCache.end()) + { 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); + } }