From b53eadaec8d5a4097a4e439d6327f2a17ff7a8b0 Mon Sep 17 00:00:00 2001 From: summer <79678786+summerqB@users.noreply.github.com> Date: Wed, 29 Jun 2022 10:17:52 +0600 Subject: [PATCH] Try to recover missing tags Tags can go missing from config/resume data. Try to recover them to avoid inconsistent behavior. Original PR: #17290. --- src/base/bittorrent/session.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index bd7b7c7fb..ece6f6ee8 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -4537,6 +4537,24 @@ void Session::startUpTorrents() } } + Algorithm::removeIf(resumeData.tags, [this, &torrentID](const QString &tag) + { + if (hasTag(tag)) + return false; + + if (addTag(tag)) + { + LogMsg(tr("Detected inconsistent data: tag is missing from the configuration file." + " Tag will be recovered." + " Torrent: \"%1\". Tag: \"%2\"").arg(torrentID.toString(), tag), Log::WARNING); + return false; + } + + LogMsg(tr("Detected inconsistent data: invalid tag. Torrent: \"%1\". Tag: \"%2\"") + .arg(torrentID.toString(), tag), Log::WARNING); + return true; + }); + qDebug() << "Starting up torrent" << torrentID.toString() << "..."; if (!loadTorrent(resumeData)) {