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. 13
      src/base/bittorrent/session.cpp

13
src/base/bittorrent/session.cpp

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

Loading…
Cancel
Save