mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-10-17 05:14:19 +02:00
decideOrphans guards on the disk scan coming back empty, but the failure mode it needs to defend against is per-root. _discoverKbFiles() walks kb_uploads and zim in a loop and skips a missing root rather than failing, because a fresh install legitimately has no kb_uploads yet. So if the zim root is relocated, renamed, or not yet mounted (#1050), the scan still returns a non-empty list from kb_uploads. The empty-scan guard never fires, filterOrphanCandidates has no way to tell a root that scanned clean from one that was never there, and every ZIM in the index is classified as an orphan and purged in a single batch. On a Wikipedia-scale knowledge base that is millions of vectors and a multi-hour re-embed. It is reachable from the UI: scanAndSyncStorage is POST /rag/sync, so the button pressed when the knowledge base looks wrong is the button that empties it. _discoverKbFilesWithRoots() now reports which roots were walked, and filterOrphanCandidates allowlists against that list instead of the configured roots. A root that wasn't there contributes no candidates; a root that scanned clean and held no files still yields its orphans, so the legitimate purge path is unchanged. The empty-scan guard becomes the degenerate case of the same rule rather than a separate one. Also builds the unit-test paths with join() instead of POSIX literals. Written as '/data/...' the filterOrphanCandidates cases pass on Linux CI and fail on Windows, where sep is backslash and no source ever matches a prefix, which is exactly where they would be run while changing this. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| controllers | ||
| data | ||
| exceptions | ||
| jobs | ||
| middleware | ||
| models | ||
| services | ||
| utils | ||
| validators | ||