diff options
Diffstat (limited to 'ui/src/lib/DownloadMonitor.svelte')
| -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; |