From 9c8a12f25c2ae0c15946a795bdfa376d5cab8030 Mon Sep 17 00:00:00 2001 From: Fazri Gading Date: Sun, 25 Jan 2026 01:58:54 +0800 Subject: [PATCH] fix: lastProgressTime variable init --- backend/utils/fileManager.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/utils/fileManager.js b/backend/utils/fileManager.js index a736565..576cc96 100644 --- a/backend/utils/fileManager.js +++ b/backend/utils/fileManager.js @@ -71,6 +71,7 @@ async function downloadFile(url, dest, progressCallback, maxRetries = 5) { // Create AbortController for proper stream control const controller = new AbortController(); let hasReceivedData = false; + let lastProgressTime = Date.now(); // Initialize before timeout // Smart overall timeout - only trigger if no progress for extended period const overallTimeout = setInterval(() => { @@ -135,7 +136,7 @@ async function downloadFile(url, dest, progressCallback, maxRetries = 5) { const contentLength = response.headers['content-length']; const totalSize = contentLength ? parseInt(contentLength, 10) + startByte : 0; // Adjust for resume let downloaded = startByte; // Start with existing bytes - let lastProgressTime = Date.now(); + lastProgressTime = Date.now(); // Update time after response received const startTime = Date.now(); // Check network status before attempting download