Don't corrupt IDs of v2 torrents

PR #16841.
This commit is contained in:
Vladimir Golovnev
2022-04-09 11:53:17 +03:00
committed by GitHub
parent 8306a41d11
commit d7e9533e8c

View File

@@ -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<LoadTorrentParams> loadPreferredResumeDataResult = startupStorage->load(torrentID);
if (loadPreferredResumeDataResult)
if (indexedTorrents.contains(torrentID))
{
std::shared_ptr<lt::torrent_info> ti = resumeData.ltAddTorrentParams.ti;
resumeData = *loadPreferredResumeDataResult;
if (!resumeData.ltAddTorrentParams.ti)
resumeData.ltAddTorrentParams.ti = ti;
skippedIDs.insert(torrentID);
const std::optional<LoadTorrentParams> loadPreferredResumeDataResult = startupStorage->load(torrentID);
if (loadPreferredResumeDataResult)
{
std::shared_ptr<lt::torrent_info> ti = resumeData.ltAddTorrentParams.ti;
resumeData = *loadPreferredResumeDataResult;
if (!resumeData.ltAddTorrentParams.ti)
resumeData.ltAddTorrentParams.ti = ti;
}
}
}
}