Skip to content

fix(content): resolve current ZIM URL before download#1091

Merged
jakeaturner merged 2 commits into
Crosstalk-Solutions:devfrom
NgoQuocViet2001:fix/1045-live-zim-download-url
Jul 21, 2026
Merged

fix(content): resolve current ZIM URL before download#1091
jakeaturner merged 2 commits into
Crosstalk-Solutions:devfrom
NgoQuocViet2001:fix/1045-live-zim-download-url

Conversation

@NgoQuocViet2001

@NgoQuocViet2001 NgoQuocViet2001 commented Jul 13, 2026

Copy link
Copy Markdown

Summary

  • Resolve curated ZIM downloads against the live Kiwix catalog before dispatch.
  • Keep static manifest values as a fallback when no current catalog entry is available.
  • Preserve newer manifest metadata if the catalog temporarily lags.
  • Compare YYYY-M / YYYY-MM versions numerically so October is newer than February.
  • Add unit coverage for live, fallback, missing-size, older-catalog, and non-padded-month cases.

Problem

Curated manifests pin dated ZIM URLs. Kiwix rotates filenames and removes old files, so fresh downloads can return 404 until the JSON is manually refreshed.

Solution

Reuse the existing bounded KiwixCatalogService.getLatestForResources() lookup used by the updater, then dispatch with the resolved URL, version, and size. Per-resource catalog failures produce no map entry, so the static manifest remains the fallback.

Version comparison parses the catalog's year/month values numerically, avoiding lexicographic ordering errors such as 2026-10 < 2026-2.

Closes #1045

Verification

  • npx tsx --test tests/unit/zim_download_resolution.spec.ts — 5/5 passed
  • npm run typecheck
  • npm run build
  • npx prettier --check app/utils/zim_download_resolution.ts tests/unit/zim_download_resolution.spec.ts
  • npx eslint app/utils/zim_download_resolution.ts tests/unit/zim_download_resolution.spec.ts
  • git diff --check

Local environment note

A full Adonis test boot on Windows is blocked by @openzim/libzim, which has no Windows native binding. The focused unit suite runs directly without booting the native service; the repository's Linux CI remains authoritative for the native suite.

@chriscrosstalk

Copy link
Copy Markdown
Collaborator

Reviewed this against the current KiwixCatalogService and it's the right approach: reusing the bounded getLatestForResources() lookup, resolving at dispatch, and falling back to the static manifest per-resource when the catalog lags or the box is offline. The version compare matches the YYYY-MM convention pickNewestZim already uses, the offline fallback path is correct, and the unit coverage hits the cases that matter. This is exactly what #1045 was asking for. Nice work, and thanks for the tests.

@NgoQuocViet2001

Copy link
Copy Markdown
Author

@chriscrosstalk thanks for the detailed review — appreciate it!

@jakeaturner jakeaturner left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NgoQuocViet2001 this is a great addition, thank you! Only one small caveat that will need to be addressed before merge: because the version field is a string, plain comparison will break in some cases, for example, '2026-10' < '2026-2'. We'll need to either attempt to parse the version to a date object first, or break it up into something like a tuple and parse as ints (e.g. [2026, 10]) so we can avoid those edge-cases.

@NgoQuocViet2001
NgoQuocViet2001 force-pushed the fix/1045-live-zim-download-url branch from 223cde5 to c69f4c0 Compare July 21, 2026 02:16
@NgoQuocViet2001

Copy link
Copy Markdown
Author

@jakeaturner Thanks for catching this. Fixed in c69f4c0: ZIM year/month versions are now parsed and compared numerically, so 2026-10 correctly wins over 2026-2. I also added the exact regression case; the focused suite passes 5/5, along with typecheck, lint, formatting, and the production build.

@jakeaturner jakeaturner left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@jakeaturner
jakeaturner merged commit c6bc40e into Crosstalk-Solutions:dev Jul 21, 2026
1 check passed
@cosmistack-bot

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 1.34.0-rc.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

caweis added a commit to caweis/project-nomad that referenced this pull request Jul 22, 2026
…out choice

Bump to 0.2.752-macos. This batch ports 10 upstream v1.34 items (UA-403 Crosstalk-Solutions#1114,
image-prune Crosstalk-Solutions#1101, CONTRIBUTING Crosstalk-Solutions#1080, Linux script colors Crosstalk-Solutions#1098, .docx Crosstalk-Solutions#1100,
debug-info Crosstalk-Solutions#1102, What's-new banner Crosstalk-Solutions#1112, ZIM extraction Crosstalk-Solutions#1044, download retry
Crosstalk-Solutions#1059, opt-in model thinking Crosstalk-Solutions#1079) and adds a Grid/Decks home-layout choice
(traditional grid now default).

Deferred with reasons: Crosstalk-Solutions#1091 (needs a Kiwix catalog service we lack), Crosstalk-Solutions#1060
(virtualization regression). Crosstalk-Solutions#1127 (nomad.md) and Crosstalk-Solutions#1063 (KB collections, Crosstalk-Solutions#883
migration) split off to focused sessions.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants