quick fix
This commit is contained in:
@@ -204,21 +204,34 @@ const notifications = (() => {
|
||||
|
||||
if (status === 'error') batch.errorCount = (batch.errorCount || 0) + 1;
|
||||
|
||||
// Only update the current-file label (single DOM element)
|
||||
const curEl = $(batchId + '-current');
|
||||
if (curEl && status === 'uploading') {
|
||||
// Update the current-file label AND progress bar during upload
|
||||
if (status === 'uploading') {
|
||||
const now = Date.now();
|
||||
const fileChanged = batch.lastLabelFile !== fileName;
|
||||
// Throttle DOM updates to avoid reflow storms (every 300ms or on file change)
|
||||
const shouldUpdate = fileChanged || now - (batch.lastLabelUpdateTs || 0) >= 300 || pct >= 100;
|
||||
if (!shouldUpdate) return;
|
||||
|
||||
// Show just the file name being uploaded (truncate long paths)
|
||||
const shortName = fileName.length > 50
|
||||
? '…' + fileName.slice(-49)
|
||||
: fileName;
|
||||
curEl.textContent = shortName;
|
||||
const curEl = $(batchId + '-current');
|
||||
if (curEl) {
|
||||
const shortName = fileName.length > 50
|
||||
? '…' + fileName.slice(-49)
|
||||
: fileName;
|
||||
curEl.textContent = shortName;
|
||||
}
|
||||
batch.lastLabelFile = fileName;
|
||||
batch.lastLabelUpdateTs = now;
|
||||
|
||||
// Update progress bar with per-file granularity:
|
||||
// overall% = (completed_files + current_file_fraction) / total_files
|
||||
const overallPct = Math.round(
|
||||
((batch.completed + (pct / 100)) / batch.totalFiles) * 100
|
||||
);
|
||||
const fillEl = $(batchId + '-fill');
|
||||
const pctEl = $(batchId + '-pct');
|
||||
if (fillEl) fillEl.style.width = overallPct + '%';
|
||||
if (pctEl) pctEl.textContent = overallPct + '%';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,8 +62,12 @@ const fileOps = {
|
||||
return new Promise((resolve) => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
const notif = window.notifications;
|
||||
xhr.timeout = timeoutMs;
|
||||
const hardDeadlineMs = Math.max(timeoutMs * 2, 180000);
|
||||
// Do NOT set xhr.timeout — it is a TOTAL deadline from send() to
|
||||
// response and would kill large uploads even while data is flowing.
|
||||
// Instead we rely on the stall timer (no progress for N seconds)
|
||||
// and a generous hard deadline that scales with file size.
|
||||
xhr.timeout = 0;
|
||||
const hardDeadlineMs = Math.max(timeoutMs * 4, 600000); // min 10 min
|
||||
let lastProgressPctSent = -1;
|
||||
|
||||
let isSettled = false;
|
||||
@@ -121,8 +125,8 @@ const fileOps = {
|
||||
resetStallTimer();
|
||||
if (e.lengthComputable) {
|
||||
const pct = Math.round((e.loaded / e.total) * 100);
|
||||
// Throttle UI updates from very chatty progress events
|
||||
if (pct === 100 || pct - lastProgressPctSent >= 10) {
|
||||
// Throttle UI updates: every 2% for smooth progress on large files
|
||||
if (pct === 100 || pct - lastProgressPctSent >= 2) {
|
||||
lastProgressPctSent = pct;
|
||||
safeUpdateFile(pct, 'uploading');
|
||||
}
|
||||
@@ -320,7 +324,11 @@ const fileOps = {
|
||||
file: file.name, size: file.size
|
||||
});
|
||||
|
||||
const result = await this._uploadFileXHR(formData, batchId, file.name);
|
||||
// Scale stall timeout with file size:
|
||||
// base 120s + 60s per GB, so a 7 GB file gets ~540s stall limit
|
||||
const sizeGB = file.size / (1024 * 1024 * 1024);
|
||||
const dynamicTimeout = Math.max(120000, 120000 + Math.ceil(sizeGB) * 60000);
|
||||
const result = await this._uploadFileXHR(formData, batchId, file.name, dynamicTimeout);
|
||||
|
||||
uploadedCount++;
|
||||
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Reference in New Issue
Block a user