Implement background daily update check (Item 4) #4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/update-worker"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
UpdateWorker.doWork() calls repository.refreshCurrentLanguage(), which reuses
the version-gated logic from Item 1:
count), replace transactionally, persist version + lastCheckedAt
Strategy: check-and-download on any connected network. The full download only
happens when the server version actually changed (typically days/weeks apart),
so the cost on metered connections is acceptable. Keeping data current matters
more for a clinical tool than saving a rare 1.1 MB transfer.
On any failure the existing database is left untouched; Result.failure() is
returned so WorkManager reschedules for the next daily window without aggressive
retries. The staleness indicator in the UI alerts the user on next open.
Scheduled from MainActivity.onCreate() with ExistingPeriodicWorkPolicy.KEEP so
repeated launches do not reset the 24-hour timer. Constraints: network connected,
battery not low. Flex window: 3 hours within each 24-hour period.
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com
UpdateWorker.doWork() calls repository.refreshCurrentLanguage(), which reuses the version-gated logic from Item 1: - GET /version.json (a few bytes) - if version unchanged: update lastCheckedAt only, no download - if version newer: download ~1.1 MB, validate (non-empty, ≥80% of current count), replace transactionally, persist version + lastCheckedAt Strategy: check-and-download on any connected network. The full download only happens when the server version actually changed (typically days/weeks apart), so the cost on metered connections is acceptable. Keeping data current matters more for a clinical tool than saving a rare 1.1 MB transfer. On any failure the existing database is left untouched; Result.failure() is returned so WorkManager reschedules for the next daily window without aggressive retries. The staleness indicator in the UI alerts the user on next open. Scheduled from MainActivity.onCreate() with ExistingPeriodicWorkPolicy.KEEP so repeated launches do not reset the 24-hour timer. Constraints: network connected, battery not low. Flex window: 3 hours within each 24-hour period. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>