fix: show MB during upload for values <100MB, GiB after

0.00008 GiB rounded to 0.0 — looked like no progress. Now shows
'16 MB' → '128 MB' → '0.5 GiB' → '1.9 GiB' as upload progresses.
This commit is contained in:
Claus Lohmar 2026-07-23 10:59:24 +00:00
parent 39cf91cbc4
commit 5f2cb3dc64
2 changed files with 7 additions and 6 deletions

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
/mnt/converter tree rm -rf /mnt/converter/tmp/*
rm -rf /mnt/converter/in/*
rm -rf /mnt/converter/out/*
rm -rf /mnt/converter/backend/__pycache__/ rm -rf /mnt/converter/backend/__pycache__/
systemctl restart vm-bench-backend.service systemctl restart vm-bench-backend.service
systemctl status vm-bench-backend.service systemctl status vm-bench-backend.service

View file

@ -159,10 +159,13 @@ async function handleUpload(formData) {
xhr.upload.addEventListener('progress', (e) => { xhr.upload.addEventListener('progress', (e) => {
if (e.lengthComputable) { if (e.lengthComputable) {
const pct = Math.round((e.loaded / e.total) * 100); const pct = Math.round((e.loaded / e.total) * 100);
setPhase('Uploading source file... ' + (e.loaded / (1024**3)).toFixed(1) + ' GiB', pct, false); const mb = (e.loaded / (1024**2)).toFixed(0);
const gb = (e.loaded / (1024**3)).toFixed(1);
const size = e.loaded > 100*1024*1024 ? gb + ' GiB' : mb + ' MB';
setPhase('Uploading source file... ' + size, pct, false);
} else { } else {
// Fallback: show bytes uploaded even without total const mb = (e.loaded / (1024**2)).toFixed(0);
setPhase('Uploading source file... ' + (e.loaded / (1024**3)).toFixed(1) + ' GiB', 0, true); setPhase('Uploading source file... ' + mb + ' MB', 0, true);
} }
}); });