Make upload history access asynchronous and release 2.1.70
CI / verify (push) Canceled after 0s

This commit is contained in:
Sucukdeluxe committed 2026-10-18 03:03:58 +02:00
1 parent 1e289ee49b
commit 8f5bcd94bf
5 files changed
+42 -31

No files matched your search

+9 -8
View File
@@ -169,10 +169,10 @@ function createCollectors(deps) {
return { errors, byCategory };
}
function listErrors(args) {
async function listErrors(args, historySnapshot) {
const a = args || {};
const cfg = loadConfig();
const history = typeof loadHistory === 'function' ? loadHistory() : cfg.history;
const history = historySnapshot ?? (typeof loadHistory === 'function' ? await loadHistory() : cfg.history);
const { errors, byCategory } = _historyErrors(history, a);
const limit = Math.min(Math.max(Number(a.limit) || 100, 1), 1000);
const window = Number.isFinite(a.sinceMs) ? `since ${new Date(a.sinceMs).toISOString()}` : 'all history';
@@ -208,11 +208,11 @@ function createCollectors(deps) {
return result;
}
function getHistory(args) {
async function getHistory(args, historySnapshot) {
const a = args || {};
const history = typeof loadHistory === 'function'
? (loadHistory() || [])
: (Array.isArray(loadConfig().history) ? loadConfig().history : []);
const history = historySnapshot ?? (typeof loadHistory === 'function'
? (await loadHistory() || [])
: (Array.isArray(loadConfig().history) ? loadConfig().history : []));
const limit = Math.min(Math.max(Number(a.limit) || 20, 1), 200);
const perHoster = stats.summarizePerHoster(history);
const recent = [...history].slice(-limit).reverse();
@@ -254,9 +254,10 @@ function createCollectors(deps) {
const a = args || {};
const errorLimit = Math.min(Math.max(Number(a.errorLimit) || 20, 1), 200);
const errArgs = Number.isFinite(a.errorSinceMs) ? { sinceMs: a.errorSinceMs, limit: errorLimit } : { limit: errorLimit };
const errors = listErrors(errArgs);
const historySnapshot = typeof loadHistory === 'function' ? await loadHistory() : loadConfig().history;
const errors = await listErrors(errArgs, historySnapshot);
const queue = getQueueState({ includeJobs: false });
const history = getHistory({ limit: 5 });
const history = await getHistory({ limit: 5 }, historySnapshot);
const warnings = [];
if (queue.source === 'persisted' && queue.stale) warnings.push('queue state is from the persisted snapshot (may lag live state; UploadManager not introspected in this build).');
if (errors.total > 0) warnings.push(`${errors.total} non-success result(s) in the error window.`);