Browse Source

Properly add torrent with new tags

First, an attempt is made to add new tags to the Session.
Closes #15105.
adaptive-webui-19844
Vladimir Golovnev (Glassez) 4 years ago committed by Vladimir Golovnev
parent
commit
6070b41c9b
  1. 21
      src/base/bittorrent/session.cpp

21
src/base/bittorrent/session.cpp

@ -838,17 +838,13 @@ bool Session::hasTag(const QString &tag) const @@ -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 @@ -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 @@ -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;
}

Loading…
Cancel
Save