From d7e9533e8ceac48241cbf2d915dc059c8b269142 Mon Sep 17 00:00:00 2001 From: Vladimir Golovnev Date: Sat, 9 Apr 2022 11:53:17 +0300 Subject: [PATCH] Don't corrupt IDs of v2 torrents PR #16841. --- src/base/bittorrent/session.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 913833c94..c017c1d9a 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -4445,21 +4445,24 @@ void Session::startUpTorrents() } else if (torrentID == torrentIDv2) { - torrentID = torrentIDv1; - needStore = true; - m_resumeDataStorage->remove(torrentIDv2); - - if (indexedTorrents.contains(torrentID)) + if (isHybrid) { - skippedIDs.insert(torrentID); + torrentID = torrentIDv1; + needStore = true; + m_resumeDataStorage->remove(torrentIDv2); - const std::optional loadPreferredResumeDataResult = startupStorage->load(torrentID); - if (loadPreferredResumeDataResult) + if (indexedTorrents.contains(torrentID)) { - std::shared_ptr ti = resumeData.ltAddTorrentParams.ti; - resumeData = *loadPreferredResumeDataResult; - if (!resumeData.ltAddTorrentParams.ti) - resumeData.ltAddTorrentParams.ti = ti; + skippedIDs.insert(torrentID); + + const std::optional loadPreferredResumeDataResult = startupStorage->load(torrentID); + if (loadPreferredResumeDataResult) + { + std::shared_ptr ti = resumeData.ltAddTorrentParams.ti; + resumeData = *loadPreferredResumeDataResult; + if (!resumeData.ltAddTorrentParams.ti) + resumeData.ltAddTorrentParams.ti = ti; + } } } }