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
commit d7e9533e8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4445,21 +4445,24 @@ void Session::startUpTorrents()
} }
else if (torrentID == torrentIDv2) else if (torrentID == torrentIDv2)
{ {
torrentID = torrentIDv1; if (isHybrid)
needStore = true;
m_resumeDataStorage->remove(torrentIDv2);
if (indexedTorrents.contains(torrentID))
{ {
skippedIDs.insert(torrentID); torrentID = torrentIDv1;
needStore = true;
m_resumeDataStorage->remove(torrentIDv2);
const std::optional<LoadTorrentParams> loadPreferredResumeDataResult = startupStorage->load(torrentID); if (indexedTorrents.contains(torrentID))
if (loadPreferredResumeDataResult)
{ {
std::shared_ptr<lt::torrent_info> ti = resumeData.ltAddTorrentParams.ti; skippedIDs.insert(torrentID);
resumeData = *loadPreferredResumeDataResult;
if (!resumeData.ltAddTorrentParams.ti) const std::optional<LoadTorrentParams> loadPreferredResumeDataResult = startupStorage->load(torrentID);
resumeData.ltAddTorrentParams.ti = ti; if (loadPreferredResumeDataResult)
{
std::shared_ptr<lt::torrent_info> ti = resumeData.ltAddTorrentParams.ti;
resumeData = *loadPreferredResumeDataResult;
if (!resumeData.ltAddTorrentParams.ti)
resumeData.ltAddTorrentParams.ti = ti;
}
} }
} }
} }