Kiwix runs in library mode reading kiwix-library.xml via --monitorLibrary. Today a missing or corrupt XML is only repaired on the download path (rebuildFromDisk after a completed download), so if the file is lost or truncated outside that flow — storage relocation, an interrupted write, manual deletion — Kiwix comes up serving an empty library with no path to recovery. Add KiwixLibraryService.ensureLibraryXmlHealthy(): reads the XML, and if it's missing (ENOENT) or fails to parse / lacks a <library> root, rebuilds it from the ZIM files on disk. A well-formed but empty library is treated as valid (no spurious rebuild), and filesystem errors other than ENOENT are surfaced rather than masked. The boot provider calls it on the already-in-library-mode path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| controllers | ||
| exceptions | ||
| jobs | ||
| middleware | ||
| models | ||
| services | ||
| utils | ||
| validators | ||