* 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
()
| 4314 | * count catches exactly that case. |
| 4315 | */ |
| 4316 | getIndexRevision(): { lastIndexedAt: number | null; fileCount: number } { |
| 4317 | const row = this.db |
| 4318 | .prepare('SELECT MAX(indexed_at) AS last, COUNT(*) AS files FROM files') |
| 4319 | .get() as { last: number | null; files: number } | undefined; |
| 4320 | return { lastIndexedAt: row?.last ?? null, fileCount: row?.files ?? 0 }; |
| 4321 | } |
| 4322 | |
| 4323 | /** |
| 4324 | * Files re-indexed strictly after `since` (ms since epoch), newest first. |