Repository navigation
Fix automatic downloads when Lagrange is backgrounded - #396
Merged
van-geaux merged 2 commits intoNov 5, 2026
Merged
Conversation
van-geaux
approved these changes
Nov 5, 2026
van-geaux
left a comment
Owner
There was a problem hiding this comment.
@JBWortley, this looks good to merge. Thanks for the thorough work on the background-download fix!
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.
Automatic downloads were failing on Android 14 when Lagrange was in the background. WorkManager tried to start its foreground service and Android rejected it, leaving the durable queue stuck. A cold worker could also mistake a valid saved profile for a signed-out session because it did not restore the stored session before checking authentication.
This keeps manual downloads foregrounded, but runs automatic transfers as ordinary constrained WorkManager jobs. A terminal failure is recorded and the bounded scan continues with the rest of the queue. The planner now uses the current authenticated session when it has one, restores the active profile's saved session when it does not, and retries temporary verification failures instead of asking the user to sign in again.
I installed the exact branch APK on a Sony XQ-CQ44 running Android 14. With Lagrange backgrounded, it completed a 9,701,925-byte PDF in the selected SD-card folder, removed the completed queue entry, and automatically advanced to the next file. I also tested a five-item Article batch with the phone locked and confirmed that transient network interruptions retained the durable queue for retry. There were no Lagrange foreground-service start denials.
The existing periodic planner remains a persistent 24-hour WorkManager job. It survives ordinary process death and reboot, and continues scanning in bounded batches after each download queue drains.
This does not add byte-range resume. Very large single files still depend on WorkManager's normal execution window and retry behavior.
Checks: