feat(reporting): purge crash/problem reports older than 1 month, on charger connect #239

Closed
opened 2026-07-03 17:12:12 +00:00 by JMR-dev · 0 comments
JMR-dev commented 2026-07-03 17:12:12 +00:00 (Migrated from github.com)

Auto-purge stored crash / problem reports older than 1 month from the device, triggered when the device connects to a charger, so debug records don't accumulate indefinitely on-device.

Trigger

Use a WorkManager job with a charging constraint (setRequiresCharging(true)) — battery-safe and consistent with the app's existing WorkManager scheduling (SyncScheduler, PruneWorker). Prefer this over a raw ACTION_POWER_CONNECTED BroadcastReceiver (can't be manifest-registered on modern Android and wakes the app unnecessarily). A periodic job that runs in a charging window, or a one-time job enqueued on charge, both work.

Purge

  • Delete stored reports with createdAtMillis older than 30 days (a RETENTION constant). The reports are file-backed via ReportStore (not Room — per the ReportUploadWorker path), so this is file cleanup, not a DB query.
  • Age is the sole criterion per the request (purge submitted and unsubmitted alike once older than the cutoff).

Notes

  • Unit-test the cutoff (a 29-day-old report survives; a 31-day-old one is purged); make it idempotent.
  • Schedule the worker at startup, mirroring PruneWorker/BackfillWorker via SyncScheduler. ReportStore is file-backed so it needs no DB access — but if any cache-DB dep sneaks in, gate it on EncryptedCacheGuard (see #224 pattern).
Auto-purge stored crash / problem reports older than **1 month** from the device, triggered **when the device connects to a charger**, so debug records don't accumulate indefinitely on-device. ## Trigger Use a WorkManager job with a **charging constraint** (`setRequiresCharging(true)`) — battery-safe and consistent with the app's existing WorkManager scheduling (`SyncScheduler`, `PruneWorker`). Prefer this over a raw `ACTION_POWER_CONNECTED` `BroadcastReceiver` (can't be manifest-registered on modern Android and wakes the app unnecessarily). A periodic job that runs in a charging window, or a one-time job enqueued on charge, both work. ## Purge - Delete stored reports with `createdAtMillis` older than 30 days (a `RETENTION` constant). The reports are **file-backed via `ReportStore`** (not Room — per the `ReportUploadWorker` path), so this is file cleanup, not a DB query. - Age is the sole criterion per the request (purge submitted and unsubmitted alike once older than the cutoff). ## Notes - Unit-test the cutoff (a 29-day-old report survives; a 31-day-old one is purged); make it idempotent. - Schedule the worker at startup, mirroring `PruneWorker`/`BackfillWorker` via `SyncScheduler`. `ReportStore` is file-backed so it needs no DB access — but if any cache-DB dep sneaks in, gate it on `EncryptedCacheGuard` (see #224 pattern).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: JMR-dev/LibreMail#239