perf: persist qBittorrent clients between requests
- Reuse client instances so auth cookies survive across requests - Eliminates redundant login round-trips on every dashboard refresh - Clients still re-authenticate automatically if session expires (403)
This commit is contained in:
@@ -96,14 +96,19 @@ class QBittorrentClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Persist clients so auth cookies survive between requests
|
||||||
|
let persistedClients = null;
|
||||||
|
|
||||||
function getClients() {
|
function getClients() {
|
||||||
|
if (persistedClients) return persistedClients;
|
||||||
const instances = getQbittorrentInstances();
|
const instances = getQbittorrentInstances();
|
||||||
if (instances.length === 0) {
|
if (instances.length === 0) {
|
||||||
logToFile('[qBittorrent] No instances configured');
|
logToFile('[qBittorrent] No instances configured');
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
logToFile(`[qBittorrent] Created ${instances.length} client(s)`);
|
logToFile(`[qBittorrent] Created ${instances.length} persistent client(s)`);
|
||||||
return instances.map(inst => new QBittorrentClient(inst));
|
persistedClients = instances.map(inst => new QBittorrentClient(inst));
|
||||||
|
return persistedClients;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getAllTorrents() {
|
async function getAllTorrents() {
|
||||||
|
|||||||
Reference in New Issue
Block a user