fix(queue): consistent "Bereit" after restart — no more Wartet/Bereit mix
buildPersistedQueueState persisted every non-aborted job's status as-is. At restart no upload manager exists, so a serialized 'queued' or 'uploading' job showed up as "Wartet" / "Upload" even though nothing was actually running — next to a "Bereit" job for the same file on a different hoster (screenshot the user sent). Collapse every non-terminal state (queued, getting-server, uploading, retrying, aborted) to 'preview' during persistence. Terminal states (done, error, skipped) survive as-is so the user keeps their history / error messages. Also clears error/result when collapsing so the restored preview row doesn't carry stale failure text.
This commit is contained in:
parent
65f8d9a0e8
commit
0c301c8182
@ -563,21 +563,29 @@ function buildPersistedQueueState() {
|
||||
return null;
|
||||
}
|
||||
|
||||
// After a restart no upload manager is running, so any in-flight state
|
||||
// (queued / getting-server / uploading / retrying / aborted) is
|
||||
// meaningless. Collapse them all to 'preview' so the queue shows a
|
||||
// consistent "Bereit" for everything that didn't actually terminate.
|
||||
// Only true terminal states (done / error / skipped) survive as-is.
|
||||
const TERMINAL = new Set(['done', 'error', 'skipped']);
|
||||
return {
|
||||
selectedUploadHosters: getSelectedHosters(),
|
||||
selectedFiles: Array.from(selectedFileMap.values()),
|
||||
queueJobs: queueJobs.map(job => ({
|
||||
id: job.id,
|
||||
file: job.file,
|
||||
fileName: job.fileName,
|
||||
hoster: job.hoster,
|
||||
// Save aborted jobs as queued so they survive restart
|
||||
status: job.status === 'aborted' ? 'queued' : job.status,
|
||||
bytesTotal: job.bytesTotal || 0,
|
||||
error: job.status === 'aborted' ? null : (job.error || null),
|
||||
result: job.result || null,
|
||||
maxAttempts: job.maxAttempts || 0
|
||||
}))
|
||||
queueJobs: queueJobs.map(job => {
|
||||
const isTerminal = TERMINAL.has(job.status);
|
||||
return {
|
||||
id: job.id,
|
||||
file: job.file,
|
||||
fileName: job.fileName,
|
||||
hoster: job.hoster,
|
||||
status: isTerminal ? job.status : 'preview',
|
||||
bytesTotal: job.bytesTotal || 0,
|
||||
error: isTerminal ? (job.error || null) : null,
|
||||
result: isTerminal ? (job.result || null) : null,
|
||||
maxAttempts: job.maxAttempts || 0
|
||||
};
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user