fix: show only live torrent transfers

This commit is contained in:
Developer
2026-07-14 21:46:20 +00:00
parent 17976eab80
commit 3871f24724
2 changed files with 15 additions and 16 deletions
@@ -462,9 +462,13 @@ def _qbit_torrent_direction(torrent: dict[str, Any]) -> str | None:
return None
def _qbit_torrent_is_active(torrent: dict[str, Any]) -> bool:
state = str(torrent.get("state") or "").lower()
return bool(_qbit_torrent_direction(torrent)) or state in _QBITTORRENT_OTHER_ACTIVE_STATES
def _qbit_torrent_transfer_direction(torrent: dict[str, Any]) -> str | None:
"""Return a direction only while qBittorrent reports nonzero throughput."""
if _safe_int(torrent.get("dlspeed")) > 0:
return "downloading"
if _safe_int(torrent.get("upspeed")) > 0:
return "uploading"
return None
class QbittorrentWidgetSource:
@@ -529,9 +533,9 @@ class QbittorrentWidgetSource:
if widget_kind == "active":
active = []
for torrent in torrents.values():
if not _qbit_torrent_is_active(torrent):
direction = _qbit_torrent_transfer_direction(torrent)
if not direction:
continue
direction = _qbit_torrent_direction(torrent)
active.append(
{
"name": torrent.get("name"),