Fix qBittorrent torrent count when empty (#106903)

* Fix qbittorrent torrent cound when empty

* lint fix

* Change based on comment
This commit is contained in:
Joe Neuman 2024-01-02 15:19:00 -08:00 committed by GitHub
parent f66438b0ce
commit 711498793a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -165,6 +165,10 @@ def count_torrents_in_states(
coordinator: QBittorrentDataCoordinator, states: list[str]
) -> int:
"""Count the number of torrents in specified states."""
# When torrents are not in the returned data, there are none, return 0.
if "torrents" not in coordinator.data:
return 0
if not states:
return len(coordinator.data["torrents"])