Periodic WorkManager jobs use KEEP, so interval/constraint changes don't apply on upgrade #96

Closed
opened 2026-07-02 02:52:46 +00:00 by JMR-dev · 0 comments
JMR-dev commented 2026-07-02 02:52:46 +00:00 (Migrated from github.com)

Surfaced during the max-effort code review of PR #46 (default fetch-all history + device-only retention). Below the cut of the reported/fixed findings — filed for tracking.

Problem. SyncScheduler enqueues the periodic sync, backfill, and prune workers with ExistingPeriodicWorkPolicy.KEEP. On an already-installed device, a future app version that changes a worker's interval or constraints will not apply the change — WorkManager keeps the previously-enqueued request.

Location. app/src/main/kotlin/org/libremail/data/sync/SyncScheduler.kt (schedulePeriodicSync / schedulePeriodicBackfill / schedulePeriodicPrune).

Impact. Maintainability/upgrade correctness: tuning a cadence or constraint won't reach existing installs. Pre-existing pattern (also used by the original periodic sync); low priority.

Suggested fix. Use ExistingPeriodicWorkPolicy.UPDATE (AndroidX WorkManager 2.8+), or version the unique-work name so a changed schedule replaces the old one on upgrade.

_Surfaced during the max-effort code review of PR #46 (default fetch-all history + device-only retention). Below the cut of the reported/fixed findings — filed for tracking._ **Problem.** `SyncScheduler` enqueues the periodic sync, backfill, and prune workers with `ExistingPeriodicWorkPolicy.KEEP`. On an already-installed device, a future app version that changes a worker's interval or constraints will not apply the change — WorkManager keeps the previously-enqueued request. **Location.** `app/src/main/kotlin/org/libremail/data/sync/SyncScheduler.kt` (`schedulePeriodicSync` / `schedulePeriodicBackfill` / `schedulePeriodicPrune`). **Impact.** Maintainability/upgrade correctness: tuning a cadence or constraint won't reach existing installs. Pre-existing pattern (also used by the original periodic sync); low priority. **Suggested fix.** Use `ExistingPeriodicWorkPolicy.UPDATE` (AndroidX WorkManager 2.8+), or version the unique-work name so a changed schedule replaces the old one on upgrade.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: JMR-dev/LibreMail#96