| 505 | } |
| 506 | |
| 507 | function estimateProgress(job, elapsedMs) { |
| 508 | const totalBytes = Number(job.totalBytes || 0); |
| 509 | const estimateMs = Math.max(MIN_ESTIMATE_MS, (totalBytes / job.estimateBps) * 1000); |
| 510 | const ratio = Math.min(0.95, elapsedMs / estimateMs); |
| 511 | const doneBytes = Math.min(totalBytes, Math.floor(totalBytes * ratio)); |
| 512 | return { ratio, doneBytes }; |
| 513 | } |
| 514 | |
| 515 | function estimateElapsedProgress(job, elapsedMs, totalBytes, doneBytes = 0) { |
| 516 | if (!Number.isFinite(totalBytes) || totalBytes <= 0) return null; |