rework scan page, add ingest-source browsing, bump version to 2026.04.15.8
Build and Push Docker Image / build (push) Has been cancelled

This commit is contained in:
2026-04-15 18:31:00 +02:00
parent c6698db51a
commit b1a9eeb481
10 changed files with 641 additions and 94 deletions
+23 -7
View File
@@ -23,6 +23,8 @@ const app = new Hono();
let queueRunning = false;
let runningProc: ReturnType<typeof Bun.spawn> | null = null;
let runningJobId: number | null = null;
let activeQueue: Job[] | null = null;
let activeSeen: Set<number> | null = null;
const LIVE_UPDATE_INTERVAL_MS = 500;
const STREAM_CHUNKS_BEFORE_YIELD = 24;
@@ -41,6 +43,17 @@ export async function yieldAfterChunk(
return 0;
}
export function enqueueUnseenJobs<T extends { id: number }>(queue: T[], seen: Set<number>, jobs: T[]): number {
let added = 0;
for (const job of jobs) {
if (seen.has(job.id)) continue;
queue.push(job);
seen.add(job.id);
added += 1;
}
return added;
}
function emitQueueStatus(
status: "running" | "paused" | "sleeping" | "idle",
extra: { until?: string; seconds?: number } = {},
@@ -56,6 +69,8 @@ async function runSequential(initial: Job[]): Promise<void> {
let first = true;
const queue: Job[] = [...initial];
const seen = new Set<number>(queue.map((j) => j.id));
activeQueue = queue;
activeSeen = seen;
while (queue.length > 0) {
const job = queue.shift() as Job;
@@ -99,15 +114,12 @@ async function runSequential(initial: Job[]): Promise<void> {
// manually clicks "Run all" again.
if (queue.length === 0) {
const more = db.prepare("SELECT * FROM jobs WHERE status = 'pending' ORDER BY created_at").all() as Job[];
for (const m of more) {
if (!seen.has(m.id)) {
queue.push(m);
seen.add(m.id);
}
}
enqueueUnseenJobs(queue, seen, more);
}
}
} finally {
activeQueue = null;
activeSeen = null;
queueRunning = false;
emitQueueStatus("idle");
}
@@ -178,8 +190,12 @@ function loadJobRow(jobId: number) {
app.post("/start", (c) => {
const db = getDb();
const pending = db.prepare("SELECT * FROM jobs WHERE status = 'pending' ORDER BY created_at").all() as Job[];
if (queueRunning && activeQueue && activeSeen) {
const queued = enqueueUnseenJobs(activeQueue, activeSeen, pending);
return c.json({ ok: true, started: 0, queued });
}
runSequential(pending).catch((err) => logError("Queue failed:", err));
return c.json({ ok: true, started: pending.length });
return c.json({ ok: true, started: pending.length, queued: pending.length });
});
// ─── Run single ───────────────────────────────────────────────────────────────