Repository navigation
ADFA-4897: ZIM/Books provisioner durability across process death - #481
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).