diff --git a/src/base/torrentfilter.cpp b/src/base/torrentfilter.cpp index e1a6243b1..a1b06a8e4 100644 --- a/src/base/torrentfilter.cpp +++ b/src/base/torrentfilter.cpp @@ -30,6 +30,7 @@ #include "bittorrent/infohash.h" #include "bittorrent/torrent.h" +#include "bittorrent/trackerentrystatus.h" const std::optional TorrentFilter::AnyCategory; const std::optional TorrentFilter::AnyID; @@ -48,6 +49,7 @@ const TorrentFilter TorrentFilter::StalledDownloadingTorrent(TorrentFilter::Stal const TorrentFilter TorrentFilter::CheckingTorrent(TorrentFilter::Checking); const TorrentFilter TorrentFilter::MovingTorrent(TorrentFilter::Moving); const TorrentFilter TorrentFilter::ErroredTorrent(TorrentFilter::Errored); +const TorrentFilter TorrentFilter::TrackerErroredTorrent(TorrentFilter::TrackerErrored); using BitTorrent::Torrent; @@ -112,6 +114,8 @@ bool TorrentFilter::setTypeByName(const QString &filter) type = Moving; else if (filter == u"errored") type = Errored; + else if (filter == u"tracker_errored") + type = TrackerErrored; return setType(type); } @@ -204,6 +208,17 @@ bool TorrentFilter::matchState(const BitTorrent::Torrent *const torrent) const return torrent->isMoving(); case Errored: return torrent->isErrored(); + case TrackerErrored: + for (BitTorrent::TrackerEntryStatus &tracker : torrent->trackers()) + { + if ((tracker.state == BitTorrent::TrackerEndpointState::NotWorking) + || (tracker.state == BitTorrent::TrackerEndpointState::TrackerError) + || (tracker.state == BitTorrent::TrackerEndpointState::Unreachable)) + { + return true; + } + } + return false; default: Q_UNREACHABLE(); break; diff --git a/src/base/torrentfilter.h b/src/base/torrentfilter.h index 39fd3e06f..471303aa8 100644 --- a/src/base/torrentfilter.h +++ b/src/base/torrentfilter.h @@ -62,6 +62,7 @@ public: Checking, Moving, Errored, + TrackerErrored, _Count }; @@ -84,6 +85,7 @@ public: static const TorrentFilter CheckingTorrent; static const TorrentFilter MovingTorrent; static const TorrentFilter ErroredTorrent; + static const TorrentFilter TrackerErroredTorrent; TorrentFilter() = default; // category & tags: pass empty string for uncategorized / untagged torrents.