1
mirror of https://github.com/qbittorrent/qBittorrent synced 2024-10-17 13:01:11 +02:00

Properly add torrent with new tags

First, an attempt is made to add new tags to the Session.
Closes #15105.
This commit is contained in:
Vladimir Golovnev (Glassez) 2021-06-16 19:03:36 +03:00 committed by Vladimir Golovnev
parent 50ddfea617
commit 6070b41c9b

View File

@ -838,17 +838,13 @@ bool Session::hasTag(const QString &tag) const
bool Session::addTag(const QString &tag)
{
if (!isValidTag(tag))
if (!isValidTag(tag) || hasTag(tag))
return false;
if (!hasTag(tag))
{
m_tags.insert(tag);
m_storedTags = m_tags.values();
emit tagAdded(tag);
return true;
}
return false;
m_tags.insert(tag);
m_storedTags = m_tags.values();
emit tagAdded(tag);
return true;
}
bool Session::removeTag(const QString &tag)
@ -2056,7 +2052,6 @@ LoadTorrentParams Session::initLoadTorrentParams(const AddTorrentParams &addTorr
LoadTorrentParams loadTorrentParams;
loadTorrentParams.name = addTorrentParams.name;
loadTorrentParams.tags = addTorrentParams.tags;
loadTorrentParams.firstLastPiecePriority = addTorrentParams.firstLastPiecePriority;
loadTorrentParams.hasSeedStatus = addTorrentParams.skipChecking; // do not react on 'torrent_finished_alert' when skipping
loadTorrentParams.contentLayout = addTorrentParams.contentLayout.value_or(torrentContentLayout());
@ -2081,6 +2076,12 @@ LoadTorrentParams Session::initLoadTorrentParams(const AddTorrentParams &addTorr
else
loadTorrentParams.category = addTorrentParams.category;
for (const QString &tag : addTorrentParams.tags)
{
if (hasTag(tag) || addTag(tag))
loadTorrentParams.tags.insert(tag);
}
return loadTorrentParams;
}