Skip to content

ADFA-4897: ZIM/Books provisioner durability across process death - #481

Merged
luisguzman-adfa merged 2 commits into
mainfrom
feat/ADFA-4897-provisioner-durability-a1
Aug 26, 2026
Merged

luisguzman-adfa merged 2 commits into
mainfrom
feat/ADFA-4897-provisioner-durability-a1

Conversation

@luisguzman-adfa

Copy link
Copy Markdown
Collaborator

Area 4 of ADFA-4893: make wizard/Get More content downloads survive app
process death without orphaning a partial or losing the order.

Keep the order until done (A1): the provisioners no longer clear the wishlist
at hand-off. The session carries each item's wishlist key and drops it only
when the item is confirmed DONE; an explicit Cancel drops only that session's
not-done items (not the whole wishlist, so an order banked via Get More during
the session survives). A process death leaves exactly the not-done items
banked, and the existing relaunch drains (SetupProgress + the LibraryHome
fallback) re-hand them off.

Re-attach on relaunch (A2): RestContentClient.start is now start-or-attach —
before creating a job it checks GET /:type/jobs and, if an ACTIVE job already
exists for the same target ids, polls that one instead of duplicating. Leans
on the durable server engine (jobs.db + reconcileOnBoot); no server change,
no persisted job handle.

Device-verified (OnePlus 7T, Android 15) on ZIM + Books: a download killed
mid-flight re-attaches to the SAME server job on reopen (active count 1 -> 1,
resumes from the on-disk pieces, not 0%), the queue resumes, and each item
ends exactly once with no orphaned partial. dash-node unchanged (1.2.7).

The ZIM/Books provisioners cleared the whole wishlist the instant they
handed off, so a process death mid-download lost the order and orphaned
the server partial (the TODO(ADFA-4874) hooks).

Now the session carries each item's wishlist key and drops the entry only
when the item is confirmed DONE (Host.onItemDone -> Wishlist.remove); an
explicit Cancel clears the rest. A process death leaves exactly the not-done
items banked, and the existing post-install drain re-hands them off — no
orphaned partial, no re-download of finished items.

- ContentDownloadSession: keys[] in the snapshot; onItemDone(key) fired on
  DONE; purge() clears it.
- Zim/BooksDownloadService: onItemDone -> Wishlist.remove; ACTION_CANCEL
  clears the wishlist; begin() gets the keys (ZIM via EXTRA_KEYS, books=ids).
- Zim/BooksProvisioner: stop clearing at hand-off; carry the keys.

Does not add re-attach to an in-flight server job on relaunch (that's A2,
pending a device check of whether a re-POST after death duplicates the job).
The server job engine is durable (jobs.db + reconcileOnBoot), so a content
job started before a process death survives. RestContentClient.start now
acts as start-or-attach: before POSTing a new job it queries GET /:type/jobs
and, if an ACTIVE job already exists for the same target ids, polls that one
instead of creating a duplicate.

Combined with A1 (the wishlist survives until each item is done) and the
existing relaunch drains (SetupProgressActivity + the LibraryHome fallback),
reopening after a kill re-drains the not-done items and re-attaches the
in-flight one to its live server job — the bar continues instead of
restarting, and no duplicate job/library entry is created.

Contained in RestContentClient (idsFromBody/idsFromJob/isActivePhase + a
GET /:type/jobs read); no server change, no persisted job handle.
@luisguzman-adfa
luisguzman-adfa merged commit dfe778c into main Aug 26, 2026
3 checks passed
@luisguzman-adfa
luisguzman-adfa deleted the feat/ADFA-4897-provisioner-durability-a1 branch August 26, 2026 23:38
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