Merge feat/516-backup-on-change into release/2.25.0

# Conflicts:
#	app/src/main/java/de/jeanlucmakiola/calendula/data/backup/AutoBackup.kt
This commit is contained in:
makiolaj committed 2026-11-18 16:16:18 +01:00
commit 55dfb08aa3
13 files changed
+655 -94

No files matched your search

+24
View File
@@ -586,6 +586,30 @@ of the backup keeps its last one. The pre-#411 fixed `calendula-backup.ics` is
the combined series' stable copy for the install that wrote it, and an
install that already had a folder stays on the combined layout.
**Backing up after a change (#516)** is opt-in. `BackupChangeJob` is a
JobScheduler job with a content trigger on the provider's root URI (the provider
notifies every change there, whoever made it: this app, a sync adapter or
another app), a 2-minute settle delay capped at 15 minutes. A trigger fires
once, so each firing queues a change run (a unique `BackupWorker`, battery not
low, queued behind one already running) and schedules the next watch under the
same id before it finishes, which carries over the changes seen meanwhile. Such
a job can't be persisted; `BackupScheduler.reconcile` re-arms it on every
process start (the boot receivers start one), without replacing a waiting watch.
Runs share the scheduled backup's lock. A change run only rewrites the stable
copies and never retries: the dated files and their retention stay on the
interval, so a day of edits can't rotate the history out. Every run that writes
something is recorded on the status line; the failure notification comes once
per failure streak, as it reaches the threshold, and the next success of any run
clears it. Since the trigger fires for any provider change (reminders, other
calendars, sync bookkeeping), each series' file (events in a fixed order) is
hashed without its `DTSTAMP`s (`auto_backup_fingerprints`, reset with the folder
and kept only while the option is on) and a change run skips the series whose
hash (bound to the copy's name) and stable copy are unchanged, without even
listing the folder when no hash moved; the hash is dropped before a copy is
rewritten. A copy that went missing is restored by the next run that lists the
folder; one a still-loading listing doesn't show, or one edited in place outside
the app, is left to the next scheduled run.
**A backup carries the series' deleted and moved occurrences.** `EXDATE` lives on
the master row and is part of `EventExportProjection`; `IcsWriter` marks an
all-day series' exclusions `VALUE=DATE`, because RFC 5545 ties `EXDATE`'s value