fix: show download progress bar percentage when content_length is known

Previously always showed indeterminate spinner (pct=0) because
total size was unknown. Now if the HEAD request returns
Content-Length, the progress bar fills proportionally.
This commit is contained in:
Claus Lohmar 2026-07-23 08:12:21 +00:00
parent 50e969f95e
commit 334883dd26

View file

@ -218,7 +218,10 @@ async function handleDownload(formData) {
let label = 'Downloading source file... ' + gb + ' GiB'; let label = 'Downloading source file... ' + gb + ' GiB';
if (pdata.speed_mbps) label += ' (' + pdata.speed_mbps + ' MB/s)'; if (pdata.speed_mbps) label += ' (' + pdata.speed_mbps + ' MB/s)';
if (pdata.eta) label += ' — ' + pdata.eta; if (pdata.eta) label += ' — ' + pdata.eta;
setPhase(label, 0, true); // Show percentage if we know total size
const totalGb = pdata.content_length_gb;
const pct = totalGb ? Math.round((pdata.file_size_gb / totalGb) * 100) : 0;
setPhase(label, pct, totalGb ? false : true);
} }
} catch (_) { /* keep polling */ } } catch (_) { /* keep polling */ }
} }