diff options
| author | 2026-01-14 13:52:46 +0800 | |
|---|---|---|
| committer | 2026-01-14 13:52:46 +0800 | |
| commit | 2e1a90fa5681d4ef40a8675820300717d8294de0 (patch) | |
| tree | 824e50c24758e39c474cb60e91246289402e8399 /ui/src/lib | |
| parent | 226661c4e700d16a9c371ae9c57ebab96ef93cd9 (diff) | |
| download | DropOut-2e1a90fa5681d4ef40a8675820300717d8294de0.tar.gz DropOut-2e1a90fa5681d4ef40a8675820300717d8294de0.zip | |
Update ui/src/lib/DownloadMonitor.svelte
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Diffstat (limited to 'ui/src/lib')
| -rw-r--r-- | ui/src/lib/DownloadMonitor.svelte | 15 |
1 files changed, 11 insertions, 4 deletions
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; |