Fix session download counter resetting when packages are removed

Session counter now uses sessionDownloadedBytes (in-memory counter)
instead of summing completed items. Removing packages after extraction
no longer resets the session total.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Sucukdeluxe
2026-03-02 19:33:58 +01:00
co-authored by Claude Opus 4.6
parent bc70ff94cc
commit 430ec7352b
2 changed files with 2 additions and 17 deletions
+1 -16
View File
@@ -891,30 +891,15 @@ export class DownloadManager extends EventEmitter {
this.resetSessionTotalsIfQueueEmpty();
let totalDownloaded = 0;
let totalFiles = 0;
for (const item of Object.values(this.session.items)) {
if (item.status === "completed") {
totalDownloaded += item.downloadedBytes;
totalFiles += 1;
}
}
if (this.session.running) {
let visibleRunBytes = 0;
for (const itemId of this.runItemIds) {
const item = this.session.items[itemId];
if (item) {
visibleRunBytes += item.downloadedBytes;
}
}
totalDownloaded += Math.max(0, this.session.totalDownloadedBytes - visibleRunBytes);
} else {
totalDownloaded = Math.max(totalDownloaded, this.session.totalDownloadedBytes);
}
const stats = {
totalDownloaded,
totalDownloaded: this.sessionDownloadedBytes,
totalDownloadedAllTime: this.settings.totalDownloadedAllTime,
totalFiles,
totalPackages: this.session.packageOrder.length,