Skip to content

Commit

Permalink
Properly add torrent with new tags
Browse files Browse the repository at this point in the history
First, an attempt is made to add new tags to the Session.
Closes qbittorrent#15105.
  • Loading branch information
glassez committed Jun 18, 2021
1 parent 50ddfea commit 6070b41
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/base/bittorrent/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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());
Expand All @@ -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;
}

Expand Down

0 comments on commit 6070b41

Please sign in to comment.