From c4a5c059499d3f5cf0c3661fdc8ea0face2fc4a2 Mon Sep 17 00:00:00 2001 From: Gauvain Date: Wed, 15 Jul 2026 00:33:49 +0200 Subject: [PATCH] fix(downloads): include trickplay files in the storage usage total --- providers/Downloads/fileOperations.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/providers/Downloads/fileOperations.ts b/providers/Downloads/fileOperations.ts index 6a0387401..052409986 100644 --- a/providers/Downloads/fileOperations.ts +++ b/providers/Downloads/fileOperations.ts @@ -97,6 +97,9 @@ export function getDownloadedItemSize(id: string): number { export function calculateTotalDownloadedSize(): number { const items = getAllDownloadedItems(); return items.reduce((sum, item) => { + // Trickplay bytes count too — getDownloadedItemSize models per-item size + // as video + trickplay, the total must match. + const trickplaySize = item.trickPlayData?.size ?? 0; // Read the live file size on disk so the total reflects actual usage and // self-heals items whose stored videoFileSize is 0 (old schema, or // `fileInfo.size` was undefined at download time). Fall back to the stored @@ -105,12 +108,12 @@ export function calculateTotalDownloadedSize(): number { try { const file = new File(filePathToUri(item.videoFilePath)); if (file.exists) { - return sum + (file.size ?? item.videoFileSize ?? 0); + return sum + (file.size ?? item.videoFileSize ?? 0) + trickplaySize; } } catch (error) { console.warn("Failed to stat downloaded file for size:", error); } } - return sum + (item.videoFileSize ?? 0); + return sum + (item.videoFileSize ?? 0) + trickplaySize; }, 0); }