From 2e1a90fa5681d4ef40a8675820300717d8294de0 Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Wed, 14 Jan 2026 13:52:46 +0800 Subject: Update ui/src/lib/DownloadMonitor.svelte Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- ui/src/lib/DownloadMonitor.svelte | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'ui/src/lib') diff --git a/ui/src/lib/DownloadMonitor.svelte b/ui/src/lib/DownloadMonitor.svelte index 79adff5..9adef67 100644 --- a/ui/src/lib/DownloadMonitor.svelte +++ b/ui/src/lib/DownloadMonitor.svelte @@ -98,12 +98,19 @@ } } - // Estimate remaining time based on files remaining + // Estimate remaining time if (downloadSpeed > 0 && completedFiles < totalFiles) { - // Rough estimate: assume average file size based on downloaded data - const avgBytesPerFile = completedFiles > 0 ? totalDownloadedBytes / completedFiles : totalDownloadedBytes; const remainingFiles = totalFiles - completedFiles; - const estimatedRemainingBytes = avgBytesPerFile * remainingFiles; + let estimatedRemainingBytes: number; + + if (completedFiles > 0) { + // Use average size of completed files to estimate remaining files + const avgBytesPerCompletedFile = totalDownloadedBytes / completedFiles; + estimatedRemainingBytes = avgBytesPerCompletedFile * remainingFiles; + } else { + // No completed files yet: estimate based only on current file's remaining bytes + estimatedRemainingBytes = Math.max(totalBytes - downloadedBytes, 0); + } etaSeconds = estimatedRemainingBytes / downloadSpeed; } else { etaSeconds = 0; -- cgit v1.2.3-70-g09d2