Local models: Reload button, scans keep their files in step

Files tab → Reload asks the worker for a scan and waits until it has
finished. Every scan now syncs local models' file lists with their
folders (new, resized, removed files; README) and settles the status.
Skipped while a job runs, and for a folder that is gone or too big.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pascal LinxweilerandClaude Opus 5.5 committed 2026-11-08 00:55:03 +01:00
1 parent f862717158
commit 80d71a1bc9
9 files changed
+218 -15

No files matched your search

+10 -2
View File
@@ -30,6 +30,14 @@ export async function localFolderExists(path: string): Promise<boolean> {
}
/** Ask the worker to scan MODELS_DIR now (it picks this up with its next heartbeat). */
export async function requestFolderScan(): Promise<void> {
await db().update(workerState).set({ scanRequestedAt: new Date() }).where(eq(workerState.id, "worker"));
export async function requestFolderScan(): Promise<Date> {
const now = new Date();
await db().update(workerState).set({ scanRequestedAt: now }).where(eq(workerState.id, "worker"));
return now;
}
/** When the last scan finished (ms since epoch), or null if the worker never scanned. */
export async function getScanState(): Promise<{ lastScanAt: number | null }> {
const row = await db().query.workerState.findFirst({ columns: { lastScanAt: true }, where: eq(workerState.id, "worker") });
return { lastScanAt: row?.lastScanAt?.getTime() ?? null };
}