diff --git a/CHANGELOG.md b/CHANGELOG.md index 7188a920..8fd56d40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,9 +15,10 @@ - Minimum cxxopts version is 3.1.1 - Minimum gettext version is 0.21 - Removed dependency on Qt Concurrent module -- Notification portal is used for notification in Flatpak - Breeze is used as a fallback icon theme and should be installed as a runtime dependency - Clarified runtime dependency on Qt's SVG image format plugin +- Notification portal is used for notification in Flatpak +- Added workaround for Transmission not showing an error for torrent when all trackers have failed - Networking and some other async code is rewritten using C++ coroutines. Hopefully nothing is broken :) ### Fixed diff --git a/src/rpc/torrent.cpp b/src/rpc/torrent.cpp index 5ea66027..78da12eb 100644 --- a/src/rpc/torrent.cpp +++ b/src/rpc/torrent.cpp @@ -247,6 +247,7 @@ namespace tremotesf { updateProperty(*key, i.value(), changed, firstTime, rpc); } } + applyTrackerErrorWorkaround(changed); return changed; } @@ -264,6 +265,7 @@ namespace tremotesf { updateProperty(*key, values[static_cast(i)], changed, firstTime, rpc); } } + applyTrackerErrorWorkaround(changed); return changed; } @@ -450,6 +452,24 @@ namespace tremotesf { throw std::logic_error(fmt::format("Can't update key {}", static_cast(intKey))); } + void TorrentData::applyTrackerErrorWorkaround(bool& changed) { + // Sometimes Transmission doesn't propagate tracker error to the torrent's status + if (error != Error::None) { + return; + } + if (trackers.empty()) { + return; + } + // Only set error if *all* trackers have an error + if (std::ranges::any_of(trackers, [](const Tracker& tracker) { return tracker.errorMessage().isEmpty(); })) { + return; + } + // Set error from first tracker + error = Error::TrackerError; + errorString = trackers.front().errorMessage(); + changed = true; + } + Torrent::Torrent(int id, const QJsonObject& object, Rpc* rpc, QObject* parent) : QObject(parent), mRpc(rpc) { mData.id = id; [[maybe_unused]] const bool changed = mData.update(object, true, rpc); diff --git a/src/rpc/torrent.h b/src/rpc/torrent.h index 8fb3f833..510ccd34 100644 --- a/src/rpc/torrent.h +++ b/src/rpc/torrent.h @@ -131,6 +131,7 @@ namespace tremotesf { void updateProperty( TorrentData::UpdateKey key, const QJsonValue& value, bool& changed, bool firstTime, const Rpc* rpc ); + void applyTrackerErrorWorkaround(bool& changed); }; class Torrent final : public QObject { diff --git a/src/rpc/tracker.h b/src/rpc/tracker.h index 2094df52..e74c2f07 100644 --- a/src/rpc/tracker.h +++ b/src/rpc/tracker.h @@ -37,7 +37,7 @@ namespace tremotesf { int tier() const { return mTier; } Status status() const { return mStatus; }; - QString errorMessage() const { return mErrorMessage; }; + const QString& errorMessage() const { return mErrorMessage; }; int peers() const { return mPeers; }; int seeders() const { return mSeeders; }