This commit is contained in:
Ashish Bhate 2025-07-06 00:43:43 +08:00 committed by GitHub
commit 5c22ce5b39
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 0 deletions

View file

@ -30,6 +30,7 @@
#include "bittorrent/infohash.h" #include "bittorrent/infohash.h"
#include "bittorrent/torrent.h" #include "bittorrent/torrent.h"
#include "bittorrent/trackerentrystatus.h"
const std::optional<QString> TorrentFilter::AnyCategory; const std::optional<QString> TorrentFilter::AnyCategory;
const std::optional<TorrentIDSet> TorrentFilter::AnyID; const std::optional<TorrentIDSet> TorrentFilter::AnyID;
@ -48,6 +49,7 @@ const TorrentFilter TorrentFilter::StalledDownloadingTorrent(TorrentFilter::Stal
const TorrentFilter TorrentFilter::CheckingTorrent(TorrentFilter::Checking); const TorrentFilter TorrentFilter::CheckingTorrent(TorrentFilter::Checking);
const TorrentFilter TorrentFilter::MovingTorrent(TorrentFilter::Moving); const TorrentFilter TorrentFilter::MovingTorrent(TorrentFilter::Moving);
const TorrentFilter TorrentFilter::ErroredTorrent(TorrentFilter::Errored); const TorrentFilter TorrentFilter::ErroredTorrent(TorrentFilter::Errored);
const TorrentFilter TorrentFilter::TrackerErroredTorrent(TorrentFilter::TrackerErrored);
using BitTorrent::Torrent; using BitTorrent::Torrent;
@ -112,6 +114,8 @@ bool TorrentFilter::setTypeByName(const QString &filter)
type = Moving; type = Moving;
else if (filter == u"errored") else if (filter == u"errored")
type = Errored; type = Errored;
else if (filter == u"tracker_errored")
type = TrackerErrored;
return setType(type); return setType(type);
} }
@ -204,6 +208,17 @@ bool TorrentFilter::matchState(const BitTorrent::Torrent *const torrent) const
return torrent->isMoving(); return torrent->isMoving();
case Errored: case Errored:
return torrent->isErrored(); 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: default:
Q_UNREACHABLE(); Q_UNREACHABLE();
break; break;

View file

@ -62,6 +62,7 @@ public:
Checking, Checking,
Moving, Moving,
Errored, Errored,
TrackerErrored,
_Count _Count
}; };
@ -84,6 +85,7 @@ public:
static const TorrentFilter CheckingTorrent; static const TorrentFilter CheckingTorrent;
static const TorrentFilter MovingTorrent; static const TorrentFilter MovingTorrent;
static const TorrentFilter ErroredTorrent; static const TorrentFilter ErroredTorrent;
static const TorrentFilter TrackerErroredTorrent;
TorrentFilter() = default; TorrentFilter() = default;
// category & tags: pass empty string for uncategorized / untagged torrents. // category & tags: pass empty string for uncategorized / untagged torrents.