mirror of
https://github.com/nimbold/Firelink.git
synced 2026-09-03 06:27:57 +00:00
fix(downloads): harden queue reordering and summary stats
This commit is contained in:
@@ -42,11 +42,13 @@ const effectiveByteState = (
|
||||
const totalBytes = usesStoredMediaTotal
|
||||
? usableBytes(download.totalBytes)
|
||||
: usableBytes(progress?.total_bytes) ?? usableBytes(download.totalBytes);
|
||||
const downloadedBytes =
|
||||
usableBytes(progress?.downloaded_bytes) ??
|
||||
usableBytes(download.downloadedBytes) ??
|
||||
(download.status === 'completed' ? totalBytes : undefined) ??
|
||||
(canInferNoDownloadedBytes(download) ? 0 : undefined);
|
||||
const downloadedBytes = download.status === 'completed'
|
||||
? usableBytes(download.downloadedBytes) ??
|
||||
usableBytes(progress?.downloaded_bytes) ??
|
||||
totalBytes
|
||||
: usableBytes(progress?.downloaded_bytes) ??
|
||||
usableBytes(download.downloadedBytes) ??
|
||||
(canInferNoDownloadedBytes(download) ? 0 : undefined);
|
||||
const totalIsEstimate = usesStoredMediaTotal
|
||||
? storedTotalIsEstimate
|
||||
: (progress?.total_is_estimate ?? storedTotalIsEstimate) === true;
|
||||
@@ -89,6 +91,13 @@ export const summarizeDownloads = (
|
||||
}
|
||||
}
|
||||
|
||||
if (download.status === 'completed') {
|
||||
// A completed row is terminal even when a delayed progress event still
|
||||
// carries an old partial denominator. Never expose that stale value as
|
||||
// remaining work in the aggregate status bar.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (
|
||||
state.totalBytes === undefined ||
|
||||
state.downloadedBytes === undefined ||
|
||||
|
||||
Reference in New Issue
Block a user