Skip to content

ADFA-4832 (Phase 1): add ZIM on the live system via the in-server socket.io channel - #249

Merged
luisguzman-adfa merged 3 commits into
mainfrom
feat/ADFA-4832-live-zim
Jul 23, 2026
Merged

luisguzman-adfa merged 3 commits into
mainfrom
feat/ADFA-4832-live-zim

Conversation

@luisguzman-adfa

Copy link
Copy Markdown
Collaborator

Fixes the "Get more → add Wikipedia/ZIM on a running system breaks Kiwix" bug. That path indexed via a second proot (iiab-make-kiwix-lib) over the live rootfs, colliding with the running server. It now goes through the already-deployed in-server dashboard socket.io channel, so the running server downloads + indexes in-process — no second proot.

Changes:

  • New LiveContentClient (socket.io client): emits start_kiwix_download; maps kiwix_terminal_output / kiwix_process_status / refresh_kiwix_catalog to progress / indexing / done / error (reuses the aria2 % regex; success = "Indexing complete"/refresh, failure = error line or isRunning:false with no refresh).
  • InstallService.downloadAndIndexKiwix branches on ServerStateRepository.alive: live channel when the server is up; the existing app-side aria2 + proot path stays for fresh installs (server down, exclusive rootfs). The foreground InstallService owns the socket, so UI/config changes don't drop the job.
  • On the live path we finish after the ZIM and skip the maps proot, to avoid re-introducing a collision.
  • Adds io.socket:socket.io-client:2.1.0 (org.json excluded). Decision recorded in controller/docs/ADR-4832-live-content-channel.md.

Scope / follow-ups (Phase 2): durable, resumable jobs + a REST start/poll contract (Android-appropriate, survives socket/UI drops); migrate maps/books to the channel; harden the dashboard packaging (compile JS, pdsm supervise); port the IPv4/IPv6 profiler server-side.

Note: the sandbox can't build/run Android — needs on-device verification (add a ZIM on a running system: Kiwix keeps working, no second proot; progress + completion show in the overlay; error surfaces safely).

The in-server dashboard downloaded ZIMs with a leaner aria2 flag set than the
app's better-tested downloader, risking divergent behaviour. Mirror the app's
flags in kiwix.socket.ts: --continue, --allow-overwrite, --auto-file-renaming=false,
-x4 / --split=16 (MetalinkSplit CONNECTIONS_PER_MIRROR / MAX_SPLIT),
--follow-metalink=mem, --check-integrity (verify .meta4 SHA-256),
--console-log-level=warn, --summary-interval=1, --download-result=hide.

Add cross-referencing SYNC notes in both files (Aria2Manager is the reference)
listing the intentional divergences: Debian system CA vs bundled cacert; container
DNS (--async-dns=false) vs ApplyDnsUseCase + IPv4 profiler; no DHT/BT yet; and the
app-only pre-reconcile/resume via MetalinkSplit + DownloadVerifier.
@luisguzman-adfa
luisguzman-adfa merged commit ceab618 into main Jul 23, 2026
4 checks passed
@luisguzman-adfa
luisguzman-adfa deleted the feat/ADFA-4832-live-zim branch July 23, 2026 21:53
…ket.io channel

On a running system, 'Get more -> add ZIM' indexed via a second proot
(iiab-make-kiwix-lib) that collided with the live server and broke Kiwix. Route
that path through the already-deployed in-server dashboard socket.io channel: the
running server downloads + indexes in-process (no new proot). The foreground
InstallService owns the connection so UI/config changes don't drop the job.

- New LiveContentClient (socket.io): emits start_kiwix_download; maps
  kiwix_terminal_output/process_status/refresh_kiwix_catalog to progress/done/error.
- InstallService.downloadAndIndexKiwix branches on ServerStateRepository.alive:
  live channel when the server is up; the app-side aria2+proot path stays for
  fresh installs (server down, exclusive rootfs).
- Live path finishes after the ZIM (skips the maps proot) to avoid a fresh
  collision; maps/books migration + a durable REST job contract are Phase 2.
- Adds io.socket:socket.io-client (org.json excluded). ADR in controller/docs.

Needs on-device verification (sandbox can't build/run Android).
- LiveContentClient: buffered kiwix_terminal_output events carry many aria2 lines
  at once; take the LAST '(NN%)...DL:' in each blob so the % reflects reality
  instead of a stale first match.
- InstallService live onProgress: append the localized k2go_rate_per_second to the
  raw rate (install_status_zim_download no longer bakes '/s' since ADFA-4830), so
  it reads e.g. '27MiB/s' again.
- dashboard kiwix.socket.ts: aria2 --summary-interval=1 so progress prints every
  second when piped (default 60s) -> real-time in the app and web UI (server-side,
  reaches installs via provisioning).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant