* The index's revision marker: how far the last sync got, and how many files * it left behind — one query, both numbers. * * This is the cheapest honest answer to "has the index moved since I last * looked". `MAX(indexed_at)` alone is not enough: a sync that only DELETES * files (a br
()
| 4425 | * count catches exactly that case. |
| 4426 | */ |
| 4427 | getIndexRevision(): { lastIndexedAt: number | null; fileCount: number } { |
| 4428 | const row = this.db |
| 4429 | .prepare('SELECT MAX(indexed_at) AS last, COUNT(*) AS files FROM files') |
| 4430 | .get() as { last: number | null; files: number } | undefined; |
| 4431 | return { lastIndexedAt: row?.last ?? null, fileCount: row?.files ?? 0 }; |
| 4432 | } |
| 4433 | |
| 4434 | /** |
| 4435 | * Files re-indexed strictly after `since` (ms since epoch), newest first. |