mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 05:13:30 -07:00
refact: Move unconditional logic outside of if.
This commit is contained in:
parent
7b21b078c1
commit
3d59cb9199
1 changed files with 28 additions and 22 deletions
|
@ -1120,17 +1120,11 @@ void TorrentsController::addTrackersAction()
|
||||||
QList<BitTorrent::Torrent *> torrents;
|
QList<BitTorrent::Torrent *> torrents;
|
||||||
const QList<BitTorrent::TrackerEntry> entries = BitTorrent::parseTrackerEntries(params()[u"urls"_s]);
|
const QList<BitTorrent::TrackerEntry> entries = BitTorrent::parseTrackerEntries(params()[u"urls"_s]);
|
||||||
|
|
||||||
if (hashParam == u"*"_s)
|
|
||||||
{
|
|
||||||
// add this tracker to all torrents
|
|
||||||
torrents = BitTorrent::Session::instance()->torrents();
|
|
||||||
}
|
|
||||||
else if (hashParam.contains(u'|'))
|
|
||||||
{
|
|
||||||
// add this tracker to all torrents in the list
|
|
||||||
const QStringList idStrings = hashParam.split(u'|', Qt::SkipEmptyParts);
|
const QStringList idStrings = hashParam.split(u'|', Qt::SkipEmptyParts);
|
||||||
for (const QString &hash : idStrings)
|
for (const QString &hash : idStrings)
|
||||||
{
|
{
|
||||||
|
if (hash == u"*"_s)
|
||||||
|
continue;
|
||||||
const auto id = BitTorrent::TorrentID::fromString(hash);
|
const auto id = BitTorrent::TorrentID::fromString(hash);
|
||||||
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->getTorrent(id);
|
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->getTorrent(id);
|
||||||
if (!torrent)
|
if (!torrent)
|
||||||
|
@ -1138,6 +1132,15 @@ void TorrentsController::addTrackersAction()
|
||||||
|
|
||||||
torrents.append(torrent);
|
torrents.append(torrent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hashParam == u"*"_s)
|
||||||
|
{
|
||||||
|
// add this tracker to all torrents
|
||||||
|
torrents = BitTorrent::Session::instance()->torrents();
|
||||||
|
}
|
||||||
|
else if (hashParam.contains(u'|'))
|
||||||
|
{
|
||||||
|
// We have this, so that we wont enter the `else` and break it.
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1223,17 +1226,11 @@ void TorrentsController::removeTrackersAction()
|
||||||
|
|
||||||
QList<BitTorrent::Torrent *> torrents;
|
QList<BitTorrent::Torrent *> torrents;
|
||||||
|
|
||||||
if (hashParam == u"*"_s)
|
|
||||||
{
|
|
||||||
// remove trackers from all torrents
|
|
||||||
torrents = BitTorrent::Session::instance()->torrents();
|
|
||||||
}
|
|
||||||
else if (hashParam.contains(u'|'))
|
|
||||||
{
|
|
||||||
// remove trackers from all torrents in the list
|
|
||||||
const QStringList idStrings = hashParam.split(u'|', Qt::SkipEmptyParts);
|
const QStringList idStrings = hashParam.split(u'|', Qt::SkipEmptyParts);
|
||||||
for (const QString &hash : idStrings)
|
for (const QString &hash : idStrings)
|
||||||
{
|
{
|
||||||
|
if (hash == u"*"_s)
|
||||||
|
continue;
|
||||||
const auto id = BitTorrent::TorrentID::fromString(hash);
|
const auto id = BitTorrent::TorrentID::fromString(hash);
|
||||||
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->getTorrent(id);
|
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->getTorrent(id);
|
||||||
if (!torrent)
|
if (!torrent)
|
||||||
|
@ -1241,6 +1238,15 @@ void TorrentsController::removeTrackersAction()
|
||||||
|
|
||||||
torrents.append(torrent);
|
torrents.append(torrent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hashParam == u"*"_s)
|
||||||
|
{
|
||||||
|
// remove trackers from all torrents
|
||||||
|
torrents = BitTorrent::Session::instance()->torrents();
|
||||||
|
}
|
||||||
|
else if (hashParam.contains(u'|'))
|
||||||
|
{
|
||||||
|
// Don't want to enter `else` with a `hashParam` not an id
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue