diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/data/backup/AutoBackup.kt b/app/src/main/java/de/jeanlucmakiola/calendula/data/backup/AutoBackup.kt index 084045f9..93f6a422 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/data/backup/AutoBackup.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/data/backup/AutoBackup.kt @@ -402,21 +402,24 @@ class BackupWorker( val landedLatest = mutableSetOf() for (plan in plans) { val target = plan.target + val hash = if (changeRun) { + preHashes[target.key] ?: run { + failed++ + continue + } + } else { + null + } + // Its hash still goes on record, so a later change run can stop early. + if (hash != null) rememberBlocked(plan, hash) if (!plan.backedUp(intervalOn)) { failed++ blocked++ continue } - if (changeRun) { - val hash = preHashes[target.key] ?: run { - failed++ - continue - } - rememberBlocked(plan, hash) - if (!plan.needsRefresh(hash, fingerprints, listing.files.keys, listing.complete)) { - if (plan.latestName in listing.files) landedLatest += target.key - continue - } + if (hash != null && !plan.needsRefresh(hash, fingerprints, listing.files.keys, listing.complete)) { + if (plan.latestName in listing.files) landedLatest += target.key + continue } // Read again rather than held since the pre-pass: one series' text in memory at a time. val text = export(target) ?: run { diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/data/backup/SettingsBackupEngine.kt b/app/src/main/java/de/jeanlucmakiola/calendula/data/backup/SettingsBackupEngine.kt index a46bca97..32ec9822 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/data/backup/SettingsBackupEngine.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/data/backup/SettingsBackupEngine.kt @@ -18,6 +18,7 @@ import de.jeanlucmakiola.calendula.data.prefs.SettingsPrefs import de.jeanlucmakiola.calendula.data.prefs.SpecialDatesStalledReason import de.jeanlucmakiola.calendula.data.fonts.CustomFontStore import de.jeanlucmakiola.calendula.data.prefs.SettingsKeys +import de.jeanlucmakiola.calendula.data.prefs.autoBackupScheduled import de.jeanlucmakiola.calendula.data.reminders.ReminderScanner import de.jeanlucmakiola.calendula.domain.FontRole import de.jeanlucmakiola.calendula.widget.requestWidgetRedraw @@ -128,7 +129,12 @@ class SettingsBackupEngine @Inject constructor( } } step("reminders") { reminderScanner.scan() } - step("auto backup") { BackupScheduler.reconcile(context, settingsPrefs) } + step("auto backup") { + BackupScheduler.reconcile(context, settingsPrefs) + // As in the settings screen, switching the interval (#516) backs up right away. + val active = after[SettingsKeys.autoBackupEnabled] && after[SettingsKeys.autoBackupFolderUri] != null + if (active && before.autoBackupScheduled != after.autoBackupScheduled) BackupScheduler.runNow(context) + } plan.launcherName?.let { name -> step("launcher name") { if (launcherNames.current() != name) launcherNames.set(name) } } diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 9d51307d..a37c68de 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -630,7 +630,7 @@ 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 +something, or fails to, 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