wrolpi/modules/zim
Roland cdcf771ffa kiwix: a corrupt zim must not bring down the whole server
A corrupt or partial *.zim (e.g. an interrupted download) is rejected by
kiwix-manage ("Cannot add zim ..."). start_kiwix_serve.sh could then leave
Kiwix down and reported a misleading "Could not find any Zim files" — and
if the bad zim was the only one, exit 2 killed the service with no restart.

- Import each zim independently; log and skip a failed add so the remaining
  valid zims are still served.
- Always ensure a library.xml exists (empty if needed) and exec kiwix-serve
  unconditionally, so a corrupt/absent zim never stops the server starting.
- Fix the mount-wait loop, which never incremented COUNT (infinite wait
  instead of a 30s timeout).
- Add MEDIA_DIRECTORY override so the script is testable.
- Add Restart=on-failure to wrolpi-kiwix.service (matches wrolpi-api.service)
  so transient failures self-heal.
- New test harness runs the script with fake kiwix-manage/kiwix-serve shims.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-20 13:06:46 -06:00
..
test kiwix: a corrupt zim must not bring down the whole server 2026-07-20 13:06:46 -06:00
__init__.py Zim/Kiwix (Wikipedia) feature 2023-07-10 21:30:40 -06:00
api.py Creating Zim search endpoint that searches all auto-search zim files. 2026-03-20 14:16:56 -06:00
conftest.py Using aria2c to download files. Removing custom file download functions. 2025-01-10 11:32:37 -07:00
downloader.py Migrating Kiwix downloaders. 2026-05-07 15:54:53 -06:00
errors.py Adding toggle to Channel page to stop downloading comments for certain channels. 2025-03-01 18:23:29 -07:00
kiwix.py Adding Khan Academy to zim subscriptions. Updating some kiwix catalog sizes. 2025-03-03 16:32:35 -07:00
lib.py Postgres -> SQLite hard cutover: the database moves into the media directory. 2026-07-12 14:09:37 -06:00
models.py Postgres -> SQLite hard cutover: the database moves into the media directory. 2026-07-12 14:09:37 -06:00
schema.py Adding feature which adds toggles to Zim files to enable/disable auto search. 2025-02-02 12:43:04 -07:00