Skip to content

ADFA-5094: generate the offline topic-tree bundle and publish it to R2 - #425

Merged
luisguzman-adfa merged 2 commits into
mainfrom
chore/ADFA-5094-tree-generator
Aug 17, 2026
Merged

luisguzman-adfa merged 2 commits into
mainfrom
chore/ADFA-5094-tree-generator

Conversation

@luisguzman-adfa

Copy link
Copy Markdown
Collaborator

Adds the offline topic-tree bundle to the catalog pipeline — the data half of browsing
Kolibri topics offline (the app that reads it is a separate PR).

build_kolibri_catalog.py gains a tree mode: --tree {topics,full} emits kolibri_tree.jsonl,
one folder per line with the aggregates measured over each channel's published content DB
(subtree resource count + bytes, plus each folder's direct loose-resource count/bytes). It
reads the channels' SQLite DBs directly instead of crawling the public contentnode_tree API,
which 400s on many channels and returns shallow data; a --measure flag cross-checks node
counts against the catalog. Default catalog mode is unchanged.

The catalog workflow now also runs the tree generator and uploads kolibri_tree.jsonl to
Cloudflare R2 under "kolibri-tree", the same publish() path the catalog and kiwix use. The
app pulls it on Wi-Fi; there is no APK-committed floor, so until the first pull the tree
source is empty and the picker falls back to box/Studio.

Verified: the generator run over the published DBs matches the catalog's resource total
(~352,593 vs 352,591); topics variant ~78k folders, ~3.3 MB gzip. Default catalog output
unchanged (--from-file). Workflow YAML lints; no conflict with main on either file.

Extend the catalog generator (run by publish-catalogs.yml and the refreshKolibriCatalog
gradle task) to also walk Studio's contentnode_tree and emit the topic tree, so the app can
browse channels offline. --measure walks the trees once and prints raw+gzip sizes for both
variants with a walked-vs-catalog resource cross-check; --tree {topics,full} writes the
chosen asset. topics keeps folders + a per-folder aggregate of direct loose resources
(dcount/dbytes), an order of magnitude smaller than full; the live source fills leaf titles
online. Tooling only: nothing in the APK changes yet.
…tree API

The API crawl 400s on ~half the channels and returns only shallow data (measured: 561 of
352,591 resources walked). Switch to downloading each channel's published content DB (the
.sqlite3 that remoteimport uses) and reading content_contentnode + content_file directly:
complete and reliable, one download per channel. topics now also carries per-folder subtree
bytes for the folder aggregate. Same flags (--measure / --tree {topics,full}); tooling only.
@luisguzman-adfa
luisguzman-adfa merged commit ed06f00 into main Aug 17, 2026
3 checks passed
@luisguzman-adfa
luisguzman-adfa deleted the chore/ADFA-5094-tree-generator branch August 17, 2026 23:23
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