fix(qbittorrent): add seeds/peers fields (num_seeds/num_leechs), guard empty response (closes #64)
Build and Push Docker Image / build (push) Successful in 50s
Licence Check / Licence compatibility and copyright header verification (push) Successful in 1m9s
Docs Check / Markdown lint (push) Successful in 1m19s
CI / Security audit (push) Successful in 2m8s
Docs Check / Mermaid diagram parse check (push) Successful in 2m33s
CI / Swagger Validation & Coverage (push) Successful in 2m40s
CI / Tests & coverage (push) Successful in 2m54s

This commit is contained in:
2026-05-28 15:52:52 +01:00
parent 6b73727d4e
commit 498eabc7bc
3 changed files with 38 additions and 0 deletions
+13
View File
@@ -104,6 +104,11 @@ class QBittorrentClient extends DownloadClient {
const response = await this.makeRequest(`/api/v2/sync/maindata?rid=${this.lastRid}`);
const data = response.data;
if (!data) {
logToFile(`[qBittorrent:${this.name}] Empty response from sync/maindata`);
return Array.from(this.torrentMap.values());
}
if (data.full_update) {
// Full refresh: rebuild the entire map
this.torrentMap.clear();
@@ -249,6 +254,14 @@ class QBittorrentClient extends DownloadClient {
downloaded: downloadedSize,
speed: torrent.dlspeed,
eta: torrent.eta < 0 || torrent.eta === 8640000 ? null : torrent.eta,
// Connected peer counts (Issue #64). qBittorrent exposes:
// num_seeds — connected seeds (peers we have a connection to)
// num_leechs — connected leechers (peers downloading from us)
// num_complete / num_incomplete — *swarm* totals reported by tracker
// We expose the connected counts to stay consistent with what other
// clients (e.g. Transmission via peersConnected/peersSendingToUs) report.
seeds: torrent.num_seeds ?? 0,
peers: torrent.num_leechs ?? 0,
category: torrent.category || undefined,
tags: torrent.tags ? torrent.tags.split(',').filter(tag => tag.trim()) : [],
savePath: torrent.content_path || torrent.save_path || undefined,