From b15b324965c402dab5652bc8c3032669ed09da23 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Fri, 20 Nov 2026 22:15:57 +0100 Subject: [PATCH 1/7] fix(#516): let the backup interval be switched off while backing up after changes --- .../calendula/data/backup/AutoBackup.kt | 28 +++++++++------- .../data/backup/SettingsBackupSchema.kt | 1 + .../calendula/data/prefs/SettingsPrefs.kt | 18 +++++++++- .../calendula/ui/calendars/BackupScreen.kt | 33 ++++++++++++++----- .../ui/calendars/CalendarsViewModel.kt | 14 ++++++-- app/src/main/res/values/strings.xml | 1 + 6 files changed, 71 insertions(+), 24 deletions(-) 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 51875c6f..8904eee9 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 @@ -109,16 +109,20 @@ object BackupScheduler { stopWatching() return } - // WorkManager's own floor is 15 min; the UI floors the user choice at 30. - val interval = prefs.autoBackupIntervalMinutes.first().coerceAtLeast(15L) - val request = PeriodicWorkRequestBuilder(interval, TimeUnit.MINUTES) - .setInitialDelay(interval, TimeUnit.MINUTES) - .build() - workManager.enqueueUniquePeriodicWork( - WORK_NAME, - ExistingPeriodicWorkPolicy.UPDATE, - request, - ) + if (prefs.autoBackupScheduled.first()) { + // WorkManager's own floor is 15 min; the UI floors the user choice at 30. + val interval = prefs.autoBackupIntervalMinutes.first().coerceAtLeast(15L) + val request = PeriodicWorkRequestBuilder(interval, TimeUnit.MINUTES) + .setInitialDelay(interval, TimeUnit.MINUTES) + .build() + workManager.enqueueUniquePeriodicWork( + WORK_NAME, + ExistingPeriodicWorkPolicy.UPDATE, + request, + ) + } else { + workManager.cancelUniqueWork(WORK_NAME) + } if (!prefs.autoBackupOnChange.first()) { stopWatching() } else if (watchDropped || !BackupChangeJob.isPending(context)) { @@ -238,7 +242,9 @@ class BackupWorker( if (changeRun && !prefs.autoBackupOnChange.first()) return Result.success() val folder = prefs.autoBackupFolderUri.first() ?: return Result.failure() val outcome = try { - runBackup(deps, prefs, folder.toUri(), latestOnly = changeRun) + // Without the interval there are no dated files, so every run is a change run's. + val latestOnly = changeRun || !prefs.autoBackupScheduled.first() + runBackup(deps, prefs, folder.toUri(), latestOnly = latestOnly) } catch (e: CancellationException) { throw e } catch (e: Exception) { diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/data/backup/SettingsBackupSchema.kt b/app/src/main/java/de/jeanlucmakiola/calendula/data/backup/SettingsBackupSchema.kt index 74a5ff1c..f4d7bf3d 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/data/backup/SettingsBackupSchema.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/data/backup/SettingsBackupSchema.kt @@ -64,6 +64,7 @@ internal object SettingsBackupSchema { SettingsKeys.autoBackupCombinedStored, SettingsKeys.autoBackupKeep, SettingsKeys.autoBackupOnChange, + SettingsKeys.autoBackupScheduledStored, SettingsKeys.specialDatesEnabled, SettingsKeys.specialDatesShowYear, ) + SettingsKeys.specialDateTypeEnabled.values + SettingsKeys.specialDatesTitleTemplate.values diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefs.kt b/app/src/main/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefs.kt index 8924f8ab..ee9e40fa 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefs.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefs.kt @@ -229,6 +229,7 @@ class SettingsPrefs @Inject constructor( val autoBackupKeep: Flow = prefs.flow(SettingsKeys.autoBackupKeep) val autoBackupLedger: Flow = prefs.flow(SettingsKeys.autoBackupLedger) val autoBackupOnChange: Flow = prefs.flow(SettingsKeys.autoBackupOnChange) + val autoBackupScheduled: Flow = prefs.snapshot { it.autoBackupScheduled } val autoBackupFingerprints: Flow = prefs.flow(SettingsKeys.autoBackupFingerprints) val specialDatesEnabled: Flow = prefs.flow(SettingsKeys.specialDatesEnabled) val specialDatesTypes: Flow> = prefs.snapshot { it.specialDatesTypes } @@ -523,7 +524,15 @@ class SettingsPrefs @Inject constructor( suspend fun setAutoBackupKeep(keep: Int) = prefs.set(SettingsKeys.autoBackupKeep, keep) - suspend fun setAutoBackupOnChange(enabled: Boolean) = prefs.set(SettingsKeys.autoBackupOnChange, enabled) + /** Turning it off brings the interval back for good, not only while it stays off. */ + suspend fun setAutoBackupOnChange(enabled: Boolean) { + prefs.edit { + it[SettingsKeys.autoBackupOnChange] = enabled + if (!enabled) it[SettingsKeys.autoBackupScheduledStored] = true + } + } + + suspend fun setAutoBackupScheduled(enabled: Boolean) = prefs.set(SettingsKeys.autoBackupScheduledStored, enabled) /** * Atomic, so a run's ledger writes never undo one made meanwhile (pinning @@ -1048,6 +1057,9 @@ object SettingsKeys { /** Whether a change to a backed-up calendar also refreshes the stable copies (#516). Opt-in. */ val autoBackupOnChange: Pref = booleanPref("auto_backup_on_change", false) + /** Whether the dated backups run on the interval; read as [Preferences.autoBackupScheduled]. */ + val autoBackupScheduledStored: Pref = booleanPref("auto_backup_scheduled", true) + /** Content hash of each series' stable copy, so a change run skips untouched ones (#516). */ val autoBackupFingerprints: Pref = nullableStringPref("auto_backup_fingerprints").map(::parseBackupFingerprints, ::persistBackupFingerprints) @@ -1107,6 +1119,10 @@ val Preferences.autoBackupSelection: BackupSelection excluded = this[SettingsKeys.autoBackupExcluded], ) +/** The interval can only be off while backing up after changes is on, or nothing would ever run. */ +val Preferences.autoBackupScheduled: Boolean + get() = this[SettingsKeys.autoBackupScheduledStored] || !this[SettingsKeys.autoBackupOnChange] + /** * Unset means an install from before #411: one that already had a backup * folder keeps the single file it was writing, anything else gets per-calendar diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/BackupScreen.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/BackupScreen.kt index 31d0dbb7..3828a0da 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/BackupScreen.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/BackupScreen.kt @@ -371,9 +371,21 @@ private fun BackupContent( ) GroupedRow( title = stringResource(R.string.calendars_auto_backup_interval), - summary = backupIntervalLabel(autoBackup.intervalMinutes), + summary = if (autoBackup.scheduled) { + backupIntervalLabel(autoBackup.intervalMinutes) + } else { + stringResource(R.string.calendars_auto_backup_interval_off) + }, position = Position.Middle, - onClick = onEditInterval, + trailing = { + // Off only alongside backing up after changes, or nothing would run. + Switch( + checked = autoBackup.scheduled, + onCheckedChange = viewModel::setAutoBackupScheduled, + enabled = autoBackup.onChange, + ) + }, + onClick = if (autoBackup.scheduled) onEditInterval else ({ viewModel.setAutoBackupScheduled(true) }), ) GroupedSwitchRow( title = stringResource(R.string.calendars_auto_backup_on_change), @@ -404,14 +416,17 @@ private fun BackupContent( ), checked = autoBackup.combined, onCheckedChange = viewModel::setAutoBackupCombined, - position = Position.Middle, - ) - GroupedRow( - title = stringResource(R.string.calendars_auto_backup_keep), - summary = backupKeepLabel(autoBackup.keep), - position = Position.Bottom, - onClick = onEditKeep, + position = if (autoBackup.scheduled) Position.Middle else Position.Bottom, ) + // Retention only applies to the dated files the interval writes. + if (autoBackup.scheduled) { + GroupedRow( + title = stringResource(R.string.calendars_auto_backup_keep), + summary = backupKeepLabel(autoBackup.keep), + position = Position.Bottom, + onClick = onEditKeep, + ) + } GroupedHint( if (selectedCount == 0) { stringResource(R.string.calendars_auto_backup_nothing_selected) diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/CalendarsViewModel.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/CalendarsViewModel.kt index 7e873251..0e19498b 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/CalendarsViewModel.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/CalendarsViewModel.kt @@ -109,9 +109,9 @@ class CalendarsViewModel @Inject constructor( settingsPrefs.autoBackupSelection, settingsPrefs.autoBackupCombined, settingsPrefs.autoBackupKeep, - settingsPrefs.autoBackupOnChange, - ) { base, selection, combined, keep, onChange -> - base.copy(selection = selection, combined = combined, keep = keep, onChange = onChange) + combine(settingsPrefs.autoBackupOnChange, settingsPrefs.autoBackupScheduled, ::Pair), + ) { base, selection, combined, keep, (onChange, scheduled) -> + base.copy(selection = selection, combined = combined, keep = keep, onChange = onChange, scheduled = scheduled) } .flowOn(io) .stateWhileSubscribed( @@ -301,6 +301,13 @@ class CalendarsViewModel @Inject constructor( } } + fun setAutoBackupScheduled(enabled: Boolean) { + viewModelScope.launch { + settingsPrefs.setAutoBackupScheduled(enabled) + reschedule() + } + } + fun setAutoBackupKeep(keep: Int) { viewModelScope.launch { if (settingsPrefs.autoBackupKeep.first() == keep) return@launch @@ -356,6 +363,7 @@ data class AutoBackupUiState( val combined: Boolean = false, val keep: Int = DEFAULT_BACKUP_KEEP, val onChange: Boolean = false, + val scheduled: Boolean = true, ) /** Outcome of a whole-calendar backup, surfaced once to the screen. */ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 11c2e328..045d6399 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1034,6 +1034,7 @@ Interval Every %1$s Minimum 30 minutes. + Off, only after changes Also back up after changes Updates the undated copy a few minutes after events change. Dated backups stay on the interval. Calendars From 91cb57f940cd39e12bc7fcae8e4233688fd1276e Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Wed, 25 Nov 2026 12:03:36 +0100 Subject: [PATCH 2/7] fix(#516): hide the interval switch without after-change backups and test the interval rules --- .../calendula/data/backup/AutoBackup.kt | 4 +-- .../calendula/data/prefs/SettingsPrefs.kt | 17 ++++++----- .../calendula/domain/backup/BackupPlan.kt | 6 ++++ .../calendula/ui/calendars/BackupScreen.kt | 20 ++++++++----- app/src/main/res/values/strings.xml | 1 + .../calendula/data/prefs/SettingsPrefsTest.kt | 30 +++++++++++++++++++ .../calendula/domain/backup/BackupPlanTest.kt | 16 ++++++++++ docs/ARCHITECTURE.md | 6 ++++ 8 files changed, 83 insertions(+), 17 deletions(-) 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 8904eee9..f6aadf7e 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 @@ -33,6 +33,7 @@ import de.jeanlucmakiola.calendula.data.prefs.SettingsPrefs import de.jeanlucmakiola.calendula.domain.backup.BackupFilePlan import de.jeanlucmakiola.calendula.domain.backup.BackupTarget import de.jeanlucmakiola.calendula.domain.backup.backupFingerprint +import de.jeanlucmakiola.calendula.domain.backup.backupRunLatestOnly import de.jeanlucmakiola.calendula.domain.backup.backupTargets import de.jeanlucmakiola.calendula.domain.backup.inBackupOrder import de.jeanlucmakiola.calendula.domain.backup.latestHeldElsewhere @@ -242,8 +243,7 @@ class BackupWorker( if (changeRun && !prefs.autoBackupOnChange.first()) return Result.success() val folder = prefs.autoBackupFolderUri.first() ?: return Result.failure() val outcome = try { - // Without the interval there are no dated files, so every run is a change run's. - val latestOnly = changeRun || !prefs.autoBackupScheduled.first() + val latestOnly = backupRunLatestOnly(changeRun, prefs.autoBackupScheduled.first()) runBackup(deps, prefs, folder.toUri(), latestOnly = latestOnly) } catch (e: CancellationException) { throw e diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefs.kt b/app/src/main/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefs.kt index ee9e40fa..e881688f 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefs.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefs.kt @@ -9,6 +9,7 @@ import de.jeanlucmakiola.calendula.domain.DefaultCalendarRef import de.jeanlucmakiola.calendula.domain.EventFormField import de.jeanlucmakiola.calendula.domain.FontRole import de.jeanlucmakiola.calendula.domain.backup.BackupSelection +import de.jeanlucmakiola.calendula.domain.backup.backupIntervalOn import de.jeanlucmakiola.calendula.domain.backup.COMBINED_SERIES import de.jeanlucmakiola.calendula.domain.backup.DEFAULT_BACKUP_KEEP import de.jeanlucmakiola.calendula.domain.backup.LEGACY_BACKUP_FILE @@ -524,12 +525,8 @@ class SettingsPrefs @Inject constructor( suspend fun setAutoBackupKeep(keep: Int) = prefs.set(SettingsKeys.autoBackupKeep, keep) - /** Turning it off brings the interval back for good, not only while it stays off. */ suspend fun setAutoBackupOnChange(enabled: Boolean) { - prefs.edit { - it[SettingsKeys.autoBackupOnChange] = enabled - if (!enabled) it[SettingsKeys.autoBackupScheduledStored] = true - } + prefs.edit { applyAutoBackupOnChange(it, enabled) } } suspend fun setAutoBackupScheduled(enabled: Boolean) = prefs.set(SettingsKeys.autoBackupScheduledStored, enabled) @@ -1119,9 +1116,15 @@ val Preferences.autoBackupSelection: BackupSelection excluded = this[SettingsKeys.autoBackupExcluded], ) -/** The interval can only be off while backing up after changes is on, or nothing would ever run. */ +/** Whether the dated backups run on the interval; see [backupIntervalOn]. */ val Preferences.autoBackupScheduled: Boolean - get() = this[SettingsKeys.autoBackupScheduledStored] || !this[SettingsKeys.autoBackupOnChange] + get() = backupIntervalOn(this[SettingsKeys.autoBackupScheduledStored], this[SettingsKeys.autoBackupOnChange]) + +/** Turning it off brings the interval back for good, not only while it stays off. */ +internal fun applyAutoBackupOnChange(prefs: MutablePreferences, enabled: Boolean) { + prefs[SettingsKeys.autoBackupOnChange] = enabled + if (!enabled) prefs[SettingsKeys.autoBackupScheduledStored] = true +} /** * Unset means an install from before #411: one that already had a backup diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlan.kt b/app/src/main/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlan.kt index d47101e3..de39fe12 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlan.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlan.kt @@ -311,6 +311,12 @@ fun parseBackupLedger(stored: String?): BackupLedger = parts.first().takeIf { it.isNotEmpty() && names.isNotEmpty() }?.let { it to names } }.toMap() +/** The interval can only be off while backing up after changes is on (#516), or nothing would ever run. */ +fun backupIntervalOn(stored: Boolean, onChange: Boolean): Boolean = stored || !onChange + +/** Without the interval there are no dated files, so every run only refreshes the stable copies. */ +fun backupRunLatestOnly(changeRun: Boolean, intervalOn: Boolean): Boolean = changeRun || !intervalOn + /** Closest offered retention count to [stored], so a stray value still shows a row. */ fun normalizeBackupKeep(stored: Int): Int = BACKUP_KEEP_OPTIONS.minBy { kotlin.math.abs(it - stored) } diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/BackupScreen.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/BackupScreen.kt index 3828a0da..f07846e8 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/BackupScreen.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/BackupScreen.kt @@ -377,19 +377,23 @@ private fun BackupContent( stringResource(R.string.calendars_auto_backup_interval_off) }, position = Position.Middle, - trailing = { - // Off only alongside backing up after changes, or nothing would run. - Switch( - checked = autoBackup.scheduled, - onCheckedChange = viewModel::setAutoBackupScheduled, - enabled = autoBackup.onChange, - ) + // Off is only offered alongside backing up after changes, or nothing would run. + trailing = if (autoBackup.onChange) { + { Switch(checked = autoBackup.scheduled, onCheckedChange = viewModel::setAutoBackupScheduled) } + } else { + null }, onClick = if (autoBackup.scheduled) onEditInterval else ({ viewModel.setAutoBackupScheduled(true) }), ) GroupedSwitchRow( title = stringResource(R.string.calendars_auto_backup_on_change), - summary = stringResource(R.string.calendars_auto_backup_on_change_summary), + summary = stringResource( + if (autoBackup.scheduled) { + R.string.calendars_auto_backup_on_change_summary + } else { + R.string.calendars_auto_backup_on_change_only_summary + }, + ), checked = autoBackup.onChange, onCheckedChange = viewModel::setAutoBackupOnChange, position = Position.Middle, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 045d6399..13f56e85 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1037,6 +1037,7 @@ Off, only after changes Also back up after changes Updates the undated copy a few minutes after events change. Dated backups stay on the interval. + Updates the undated copy a few minutes after events change. No dated backups. Calendars %d calendar diff --git a/app/src/test/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefsTest.kt b/app/src/test/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefsTest.kt index 6a35196f..fef0a603 100644 --- a/app/src/test/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefsTest.kt +++ b/app/src/test/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefsTest.kt @@ -932,6 +932,36 @@ class SettingsPrefsTest { assertThat(prefs.autoBackupKeep.first()).isEqualTo(10) } + @Test + fun `the backup interval is on by default and can only go off alongside after-change backups`(@TempDir tempDir: Path) = runTest { + val prefs = testSettings(tempDir) + assertThat(prefs.autoBackupScheduled.first()).isTrue() + + prefs.setAutoBackupScheduled(false) + assertThat(prefs.autoBackupScheduled.first()).isTrue() + + prefs.setAutoBackupOnChange(true) + prefs.setAutoBackupScheduled(false) + assertThat(prefs.autoBackupScheduled.first()).isFalse() + prefs.setAutoBackupScheduled(true) + assertThat(prefs.autoBackupScheduled.first()).isTrue() + } + + @Test + fun `turning after-change backups off brings the interval back for good`(@TempDir tempDir: Path) = runTest { + val prefs = testSettings(tempDir) + prefs.setAutoBackupIntervalMinutes(6 * 60L) + prefs.setAutoBackupOnChange(true) + prefs.setAutoBackupScheduled(false) + + prefs.setAutoBackupOnChange(false) + assertThat(prefs.autoBackupScheduled.first()).isTrue() + assertThat(prefs.autoBackupIntervalMinutes.first()).isEqualTo(6 * 60L) + + prefs.setAutoBackupOnChange(true) + assertThat(prefs.autoBackupScheduled.first()).isTrue() + } + @Test fun `a pre-411 install adopts its old file when the layout is pinned in place`(@TempDir tempDir: Path) = runTest { val store = testDataStore(tempDir, "test_settings") diff --git a/app/src/test/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlanTest.kt b/app/src/test/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlanTest.kt index 408a69db..a39cd873 100644 --- a/app/src/test/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlanTest.kt +++ b/app/src/test/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlanTest.kt @@ -402,4 +402,20 @@ class BackupPlanTest { assertThat(one.inBackupOrder()).isEqualTo(other.inBackupOrder()) assertThat(one.inBackupOrder().map { it.uid }).containsExactly("a", "b").inOrder() } + + @Test + fun `the interval stays on unless after-change backups cover for it`() { + assertThat(backupIntervalOn(stored = true, onChange = false)).isTrue() + assertThat(backupIntervalOn(stored = false, onChange = false)).isTrue() + assertThat(backupIntervalOn(stored = true, onChange = true)).isTrue() + assertThat(backupIntervalOn(stored = false, onChange = true)).isFalse() + } + + @Test + fun `only a run with the interval on writes dated files`() { + assertThat(backupRunLatestOnly(changeRun = false, intervalOn = true)).isFalse() + assertThat(backupRunLatestOnly(changeRun = true, intervalOn = true)).isTrue() + assertThat(backupRunLatestOnly(changeRun = false, intervalOn = false)).isTrue() + assertThat(backupRunLatestOnly(changeRun = true, intervalOn = false)).isTrue() + } } diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 9577384d..ef5c1801 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -642,6 +642,12 @@ 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. +While the option is on, the interval itself can be switched off +(`auto_backup_scheduled`, read through `backupIntervalOn`, so it never counts as +off without the option): the periodic work is cancelled and every run, including +run-now, only refreshes the stable copies, so no dated files are written or +pruned. Turning the option off sets the interval back on, at the interval it had. + **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 From 4d342c98add29c6782b39f77ac7b1b522bfb8450 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Wed, 25 Nov 2026 12:08:44 +0100 Subject: [PATCH 3/7] fix(#516): flag series the undated copy can't cover, back up when the interval returns --- .../calendula/data/backup/AutoBackup.kt | 29 ++++++++++++++----- .../calendula/data/prefs/SettingsPrefs.kt | 5 +++- .../calendula/domain/backup/BackupPlan.kt | 5 +++- .../ui/calendars/CalendarsViewModel.kt | 5 ++++ .../calendula/data/prefs/SettingsPrefsTest.kt | 9 ++++++ .../calendula/domain/backup/BackupPlanTest.kt | 10 +++++++ docs/ARCHITECTURE.md | 9 ++++-- 7 files changed, 59 insertions(+), 13 deletions(-) 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 f6aadf7e..8b08ac63 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 @@ -32,6 +32,7 @@ import de.jeanlucmakiola.calendula.data.ics.IcsExporter import de.jeanlucmakiola.calendula.data.prefs.SettingsPrefs import de.jeanlucmakiola.calendula.domain.backup.BackupFilePlan import de.jeanlucmakiola.calendula.domain.backup.BackupTarget +import de.jeanlucmakiola.calendula.domain.backup.backedUp import de.jeanlucmakiola.calendula.domain.backup.backupFingerprint import de.jeanlucmakiola.calendula.domain.backup.backupRunLatestOnly import de.jeanlucmakiola.calendula.domain.backup.backupTargets @@ -243,8 +244,7 @@ class BackupWorker( if (changeRun && !prefs.autoBackupOnChange.first()) return Result.success() val folder = prefs.autoBackupFolderUri.first() ?: return Result.failure() val outcome = try { - val latestOnly = backupRunLatestOnly(changeRun, prefs.autoBackupScheduled.first()) - runBackup(deps, prefs, folder.toUri(), latestOnly = latestOnly) + runBackup(deps, prefs, folder.toUri(), changeRun, prefs.autoBackupScheduled.first()) } catch (e: CancellationException) { throw e } catch (e: Exception) { @@ -274,10 +274,19 @@ class BackupWorker( /** * Writes each series and prunes it only once its new file has landed. A - * [latestOnly] run (#516) leaves the dated files and their retention to the + * change run (#516) leaves the dated files and their retention to the * schedule and rewrites only the stable copies whose calendars changed. + * With the interval off, no run writes dated files, so a series whose + * stable name a file of the user's holds counts as failed. */ - private suspend fun runBackup(deps: Deps, prefs: SettingsPrefs, folder: Uri, latestOnly: Boolean): RunOutcome { + private suspend fun runBackup( + deps: Deps, + prefs: SettingsPrefs, + folder: Uri, + changeRun: Boolean, + intervalOn: Boolean, + ): RunOutcome { + val latestOnly = backupRunLatestOnly(changeRun, intervalOn) val repository = deps.repository() val exporter = deps.exporter() if (!applicationContext.hasPermission(Manifest.permission.READ_CALENDAR)) return RunOutcome.Failed @@ -309,12 +318,12 @@ class BackupWorker( val trackHashes = prefs.autoBackupOnChange.first() if (!trackHashes && fingerprints.isNotEmpty()) prefs.updateAutoBackupFingerprints(folder.toString()) { emptyMap() } // A change run hashes first (null: unreadable) and leaves the folder alone when nothing moved. - val preHashes: Map = if (latestOnly) { + val preHashes: Map = if (changeRun) { targets.associate { target -> target.key to export(target)?.let { fingerprintOf(target, it) } } } else { emptyMap() } - if (latestOnly && targets.all { preHashes[it.key].let { hash -> hash != null && hash == fingerprints[it.key] } }) { + if (changeRun && targets.all { preHashes[it.key].let { hash -> hash != null && hash == fingerprints[it.key] } }) { return RunOutcome.NothingToDo } val plans = planBackupFiles( @@ -391,7 +400,11 @@ class BackupWorker( val landedLatest = mutableSetOf() for (plan in plans) { val target = plan.target - if (latestOnly) { + if (!plan.backedUp(intervalOn)) { + failed++ + continue + } + if (changeRun) { val hash = preHashes[target.key] ?: run { failed++ continue @@ -408,7 +421,7 @@ class BackupWorker( continue } val fingerprint = fingerprintOf(target, text) - if (!latestOnly) rememberBlocked(plan, fingerprint) + if (!changeRun) rememberBlocked(plan, fingerprint) val bytes = text.toByteArray(Charsets.UTF_8) // Not cancellable once a file exists: it must reach the ledger. withContext(NonCancellable) { diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefs.kt b/app/src/main/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefs.kt index e881688f..9e707163 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefs.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefs.kt @@ -529,7 +529,10 @@ class SettingsPrefs @Inject constructor( prefs.edit { applyAutoBackupOnChange(it, enabled) } } - suspend fun setAutoBackupScheduled(enabled: Boolean) = prefs.set(SettingsKeys.autoBackupScheduledStored, enabled) + /** Off only sticks while backing up after changes is on; see [applyAutoBackupOnChange]. */ + suspend fun setAutoBackupScheduled(enabled: Boolean) { + prefs.edit { if (enabled || it[SettingsKeys.autoBackupOnChange]) it[SettingsKeys.autoBackupScheduledStored] = enabled } + } /** * Atomic, so a run's ledger writes never undo one made meanwhile (pinning diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlan.kt b/app/src/main/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlan.kt index de39fe12..08b9c768 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlan.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlan.kt @@ -317,6 +317,9 @@ fun backupIntervalOn(stored: Boolean, onChange: Boolean): Boolean = stored || !o /** Without the interval there are no dated files, so every run only refreshes the stable copies. */ fun backupRunLatestOnly(changeRun: Boolean, intervalOn: Boolean): Boolean = changeRun || !intervalOn +/** Whether a run can back this series up at all: without dated files, only through its stable copy. */ +fun BackupFilePlan.backedUp(intervalOn: Boolean): Boolean = intervalOn || latestName != null + /** Closest offered retention count to [stored], so a stray value still shows a row. */ fun normalizeBackupKeep(stored: Int): Int = BACKUP_KEEP_OPTIONS.minBy { kotlin.math.abs(it - stored) } @@ -375,7 +378,7 @@ fun parseBackupFingerprints(stored: String?): BackupFingerprints = * only when its content moved on from what the copy holds (a rename changes * the name written into it), or the copy is missing. Never when the name belongs to a file of the user's, * nor when a [complete]-less listing doesn't show the copy: writing then would - * add a duplicate beside it, so that is left to the scheduled run. + * add a duplicate beside it, so that is left to the next run that isn't a change run. */ fun BackupFilePlan.needsRefresh( fingerprint: String, diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/CalendarsViewModel.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/CalendarsViewModel.kt index 0e19498b..b57cf0d0 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/CalendarsViewModel.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/CalendarsViewModel.kt @@ -296,15 +296,20 @@ class CalendarsViewModel @Inject constructor( fun setAutoBackupOnChange(enabled: Boolean) { viewModelScope.launch { + val wasScheduled = settingsPrefs.autoBackupScheduled.first() settingsPrefs.setAutoBackupOnChange(enabled) reschedule() + if (!wasScheduled && settingsPrefs.autoBackupScheduled.first()) runBackupIfActive() } } + /** Back on, it backs up right away rather than an interval later. */ fun setAutoBackupScheduled(enabled: Boolean) { viewModelScope.launch { + val wasScheduled = settingsPrefs.autoBackupScheduled.first() settingsPrefs.setAutoBackupScheduled(enabled) reschedule() + if (!wasScheduled && settingsPrefs.autoBackupScheduled.first()) runBackupIfActive() } } diff --git a/app/src/test/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefsTest.kt b/app/src/test/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefsTest.kt index fef0a603..3846afa5 100644 --- a/app/src/test/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefsTest.kt +++ b/app/src/test/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefsTest.kt @@ -962,6 +962,15 @@ class SettingsPrefsTest { assertThat(prefs.autoBackupScheduled.first()).isTrue() } + @Test + fun `switching the interval off without after-change backups leaves nothing behind`(@TempDir tempDir: Path) = runTest { + val prefs = testSettings(tempDir) + prefs.setAutoBackupScheduled(false) + + prefs.setAutoBackupOnChange(true) + assertThat(prefs.autoBackupScheduled.first()).isTrue() + } + @Test fun `a pre-411 install adopts its old file when the layout is pinned in place`(@TempDir tempDir: Path) = runTest { val store = testDataStore(tempDir, "test_settings") diff --git a/app/src/test/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlanTest.kt b/app/src/test/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlanTest.kt index a39cd873..84f60b83 100644 --- a/app/src/test/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlanTest.kt +++ b/app/src/test/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlanTest.kt @@ -418,4 +418,14 @@ class BackupPlanTest { assertThat(backupRunLatestOnly(changeRun = false, intervalOn = false)).isTrue() assertThat(backupRunLatestOnly(changeRun = true, intervalOn = false)).isTrue() } + + @Test + fun `without the interval a series whose stable name is the user's goes unbacked`() { + val free = planBackupFiles(listOf(work), emptyMap(), emptySet(), at, keep = 3).single() + val blocked = planBackupFiles(listOf(work), emptyMap(), setOf("Work.ics"), at, keep = 3).single() + + assertThat(free.backedUp(intervalOn = false)).isTrue() + assertThat(blocked.backedUp(intervalOn = false)).isFalse() + assertThat(blocked.backedUp(intervalOn = true)).isTrue() + } } diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index ef5c1801..f57cd554 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -644,9 +644,12 @@ the app, is left to the next scheduled run. While the option is on, the interval itself can be switched off (`auto_backup_scheduled`, read through `backupIntervalOn`, so it never counts as -off without the option): the periodic work is cancelled and every run, including -run-now, only refreshes the stable copies, so no dated files are written or -pruned. Turning the option off sets the interval back on, at the interval it had. +off without the option): the periodic work is cancelled and no run writes or +prunes dated files. Run-now then rewrites every stable copy, change runs only +the changed ones, and a series whose stable name a file of the user's holds +counts as failed, since nothing else backs it up. Turning the option off sets +the interval back on, at the interval it had, and turning the interval back on +either way backs up right away. **A backup carries the series' deleted and moved occurrences.** `EXDATE` lives on the master row and is part of `EventExportProjection`; `IcsWriter` marks an From 242ccd3b70ce5d36f0d197d652b039b626927c84 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Wed, 25 Nov 2026 12:12:22 +0100 Subject: [PATCH 4/7] fix(#516): don't retry a run only blocked series failed, back up on any interval switch --- .../calendula/data/backup/AutoBackup.kt | 10 +++++-- .../calendula/data/prefs/SettingsPrefs.kt | 28 +++++++++++++++---- .../ui/calendars/CalendarsViewModel.kt | 17 +++++------ .../calendula/data/prefs/SettingsPrefsTest.kt | 11 ++++++++ docs/ARCHITECTURE.md | 7 +++-- 5 files changed, 54 insertions(+), 19 deletions(-) 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 8b08ac63..084045f9 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 @@ -78,8 +78,8 @@ object BackupScheduler { /** * Reconcile the scheduled work with the saved settings: enqueue a unique - * periodic request when backup is on and a folder is set, otherwise cancel - * it. WorkManager persists the request across reboots on its own. + * periodic request when backup is on, a folder is set and the interval + * isn't switched off (#516), otherwise cancel it. WorkManager persists the request across reboots on its own. * * The first run is delayed by one interval so it doesn't follow an immediate * [runNow] with a near-identical copy. With backing up after changes on @@ -267,7 +267,8 @@ class BackupWorker( return if (outcome == RunOutcome.Failed && !changeRun) Result.retry() else Result.success() } - private enum class RunOutcome { Written, PartlyFailed, Failed, NothingToDo } + /** [Blocked]: failed only on series no retry can back up, so it isn't retried. */ + private enum class RunOutcome { Written, PartlyFailed, Failed, Blocked, NothingToDo } /** How a stable copy's write went: under its own name, under one the provider picked, or not at all. */ private enum class LatestWrite { Landed, Renamed, Failed } @@ -397,11 +398,13 @@ class BackupWorker( var written = 0 var failed = 0 + var blocked = 0 val landedLatest = mutableSetOf() for (plan in plans) { val target = plan.target if (!plan.backedUp(intervalOn)) { failed++ + blocked++ continue } if (changeRun) { @@ -447,6 +450,7 @@ class BackupWorker( return when { failed == 0 && written == 0 -> RunOutcome.NothingToDo failed == 0 -> RunOutcome.Written + written == 0 && failed == blocked -> RunOutcome.Blocked written == 0 -> RunOutcome.Failed else -> RunOutcome.PartlyFailed } diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefs.kt b/app/src/main/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefs.kt index 9e707163..15cabfea 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefs.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefs.kt @@ -231,6 +231,10 @@ class SettingsPrefs @Inject constructor( val autoBackupLedger: Flow = prefs.flow(SettingsKeys.autoBackupLedger) val autoBackupOnChange: Flow = prefs.flow(SettingsKeys.autoBackupOnChange) val autoBackupScheduled: Flow = prefs.snapshot { it.autoBackupScheduled } + + /** Read together, so the screen never shows one updated without the other. */ + val autoBackupOnChangeAndScheduled: Flow> = + prefs.snapshot { it[SettingsKeys.autoBackupOnChange] to it.autoBackupScheduled } val autoBackupFingerprints: Flow = prefs.flow(SettingsKeys.autoBackupFingerprints) val specialDatesEnabled: Flow = prefs.flow(SettingsKeys.specialDatesEnabled) val specialDatesTypes: Flow> = prefs.snapshot { it.specialDatesTypes } @@ -525,13 +529,27 @@ class SettingsPrefs @Inject constructor( suspend fun setAutoBackupKeep(keep: Int) = prefs.set(SettingsKeys.autoBackupKeep, keep) - suspend fun setAutoBackupOnChange(enabled: Boolean) { - prefs.edit { applyAutoBackupOnChange(it, enabled) } + /** Returns whether this switched the interval on or off. */ + suspend fun setAutoBackupOnChange(enabled: Boolean): Boolean = editAutoBackupScheduled { + applyAutoBackupOnChange(it, enabled) } - /** Off only sticks while backing up after changes is on; see [applyAutoBackupOnChange]. */ - suspend fun setAutoBackupScheduled(enabled: Boolean) { - prefs.edit { if (enabled || it[SettingsKeys.autoBackupOnChange]) it[SettingsKeys.autoBackupScheduledStored] = enabled } + /** + * Off only sticks while backing up after changes is on; see + * [applyAutoBackupOnChange]. Returns whether this switched the interval. + */ + suspend fun setAutoBackupScheduled(enabled: Boolean): Boolean = editAutoBackupScheduled { + if (enabled || it[SettingsKeys.autoBackupOnChange]) it[SettingsKeys.autoBackupScheduledStored] = enabled + } + + private suspend fun editAutoBackupScheduled(transform: (MutablePreferences) -> Unit): Boolean { + var switched = false + prefs.edit { + val before = it.autoBackupScheduled + transform(it) + switched = it.autoBackupScheduled != before + } + return switched } /** diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/CalendarsViewModel.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/CalendarsViewModel.kt index b57cf0d0..2e81d0c9 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/CalendarsViewModel.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/CalendarsViewModel.kt @@ -109,7 +109,7 @@ class CalendarsViewModel @Inject constructor( settingsPrefs.autoBackupSelection, settingsPrefs.autoBackupCombined, settingsPrefs.autoBackupKeep, - combine(settingsPrefs.autoBackupOnChange, settingsPrefs.autoBackupScheduled, ::Pair), + settingsPrefs.autoBackupOnChangeAndScheduled, ) { base, selection, combined, keep, (onChange, scheduled) -> base.copy(selection = selection, combined = combined, keep = keep, onChange = onChange, scheduled = scheduled) } @@ -296,20 +296,21 @@ class CalendarsViewModel @Inject constructor( fun setAutoBackupOnChange(enabled: Boolean) { viewModelScope.launch { - val wasScheduled = settingsPrefs.autoBackupScheduled.first() - settingsPrefs.setAutoBackupOnChange(enabled) + val switched = settingsPrefs.setAutoBackupOnChange(enabled) reschedule() - if (!wasScheduled && settingsPrefs.autoBackupScheduled.first()) runBackupIfActive() + if (switched) runBackupIfActive() } } - /** Back on, it backs up right away rather than an interval later. */ + /** + * Switching the interval backs up right away: back on, rather than an + * interval later; off, so a series only its dated files covered shows up. + */ fun setAutoBackupScheduled(enabled: Boolean) { viewModelScope.launch { - val wasScheduled = settingsPrefs.autoBackupScheduled.first() - settingsPrefs.setAutoBackupScheduled(enabled) + val switched = settingsPrefs.setAutoBackupScheduled(enabled) reschedule() - if (!wasScheduled && settingsPrefs.autoBackupScheduled.first()) runBackupIfActive() + if (switched) runBackupIfActive() } } diff --git a/app/src/test/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefsTest.kt b/app/src/test/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefsTest.kt index 3846afa5..587add9f 100644 --- a/app/src/test/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefsTest.kt +++ b/app/src/test/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefsTest.kt @@ -962,6 +962,17 @@ class SettingsPrefsTest { assertThat(prefs.autoBackupScheduled.first()).isTrue() } + @Test + fun `the interval setters report whether they switched it`(@TempDir tempDir: Path) = runTest { + val prefs = testSettings(tempDir) + assertThat(prefs.setAutoBackupScheduled(false)).isFalse() + assertThat(prefs.setAutoBackupOnChange(true)).isFalse() + assertThat(prefs.setAutoBackupScheduled(false)).isTrue() + assertThat(prefs.setAutoBackupScheduled(false)).isFalse() + assertThat(prefs.setAutoBackupOnChange(false)).isTrue() + assertThat(prefs.autoBackupOnChangeAndScheduled.first()).isEqualTo(false to true) + } + @Test fun `switching the interval off without after-change backups leaves nothing behind`(@TempDir tempDir: Path) = runTest { val prefs = testSettings(tempDir) diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index f57cd554..9d51307d 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -647,9 +647,10 @@ While the option is on, the interval itself can be switched off off without the option): the periodic work is cancelled and no run writes or prunes dated files. Run-now then rewrites every stable copy, change runs only the changed ones, and a series whose stable name a file of the user's holds -counts as failed, since nothing else backs it up. Turning the option off sets -the interval back on, at the interval it had, and turning the interval back on -either way backs up right away. +counts as failed (not retried), since nothing else backs it up. Turning the +option off sets the interval back on, at the interval it had; any switch of the +interval backs up right away. What the text above leaves to the next scheduled +run then waits for the next run-now. **A backup carries the series' deleted and moved occurrences.** `EXDATE` lives on the master row and is part of `EventExportProjection`; `IcsWriter` marks an From 732548a989d1ea172cd554e78d23af5798bc8ef8 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Wed, 25 Nov 2026 12:16:32 +0100 Subject: [PATCH 5/7] fix(#516): keep a blocked series' hash, back up when a settings restore switches the interval --- .../calendula/data/backup/AutoBackup.kt | 23 +++++++++++-------- .../data/backup/SettingsBackupEngine.kt | 8 ++++++- docs/ARCHITECTURE.md | 2 +- 3 files changed, 21 insertions(+), 12 deletions(-) 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 From 4a14ebde2d39b935bfb94cb8124b083f1ccffcf7 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Wed, 25 Nov 2026 15:20:11 +0100 Subject: [PATCH 6/7] fix(#516): review round 3 - restore missing stable copies on change runs, blocked series reported once, kept copies of deselected calendars suffix the name --- .../calendula/data/backup/AutoBackup.kt | 25 ++++++++++++++--- .../data/backup/SettingsBackupEngine.kt | 2 +- .../calendula/data/prefs/SettingsPrefs.kt | 8 ++++-- .../calendula/domain/backup/BackupPlan.kt | 27 ++++++++++++++----- .../calendula/data/prefs/SettingsPrefsTest.kt | 16 +++++++++++ .../calendula/domain/backup/BackupPlanTest.kt | 12 +++++++++ docs/ARCHITECTURE.md | 15 ++++++----- 7 files changed, 85 insertions(+), 20 deletions(-) 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 93f6a422..14835d9e 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 @@ -278,7 +278,8 @@ class BackupWorker( * change run (#516) leaves the dated files and their retention to the * schedule and rewrites only the stable copies whose calendars changed. * With the interval off, no run writes dated files, so a series whose - * stable name a file of the user's holds counts as failed. + * stable name a file of the user's holds counts as failed (a change run + * only when its content changed), and run-now skips current copies too. */ private suspend fun runBackup( deps: Deps, @@ -324,7 +325,11 @@ class BackupWorker( } else { emptyMap() } - if (changeRun && targets.all { preHashes[it.key].let { hash -> hash != null && hash == fingerprints[it.key] } }) { + // Unless a stable copy went missing: with the interval off, nothing else would restore it. + if (changeRun && + targets.all { preHashes[it.key].let { hash -> hash != null && hash == fingerprints[it.key] } } && + (!listing.complete || targets.all { latestFileName(it.baseName) in listing.files }) + ) { return RunOutcome.NothingToDo } val plans = planBackupFiles( @@ -410,13 +415,17 @@ class BackupWorker( } 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)) { + // Its hash still goes on record, so a later change run can stop early. + val blockedHash = hash ?: if (trackHashes) export(target)?.let { fingerprintOf(target, it) } else null + blockedHash?.let { rememberBlocked(plan, it) } + // Reported once per content: a change run doesn't fail again on one that didn't change. + if (changeRun && hash == fingerprints[target.key]) continue failed++ blocked++ continue } + if (hash != null) rememberBlocked(plan, hash) if (hash != null && !plan.needsRefresh(hash, fingerprints, listing.files.keys, listing.complete)) { if (plan.latestName in listing.files) landedLatest += target.key continue @@ -428,6 +437,14 @@ class BackupWorker( } val fingerprint = fingerprintOf(target, text) if (!changeRun) rememberBlocked(plan, fingerprint) + // Without the interval, run-now leaves a stable copy that is already current alone. + if (!changeRun && latestOnly && trackHashes && plan.latestName in listing.files && + fingerprints[target.key] == fingerprint + ) { + landedLatest += target.key + written++ + continue + } val bytes = text.toByteArray(Charsets.UTF_8) // Not cancellable once a file exists: it must reach the ledger. withContext(NonCancellable) { 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 32ec9822..9cb30cc8 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 @@ -131,7 +131,7 @@ class SettingsBackupEngine @Inject constructor( step("reminders") { reminderScanner.scan() } step("auto backup") { BackupScheduler.reconcile(context, settingsPrefs) - // As in the settings screen, switching the interval (#516) backs up right away. + // Like the settings screen, an import that switches 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) } diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefs.kt b/app/src/main/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefs.kt index 15cabfea..719405ea 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefs.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefs.kt @@ -1141,10 +1141,14 @@ val Preferences.autoBackupSelection: BackupSelection val Preferences.autoBackupScheduled: Boolean get() = backupIntervalOn(this[SettingsKeys.autoBackupScheduledStored], this[SettingsKeys.autoBackupOnChange]) -/** Turning it off brings the interval back for good, not only while it stays off. */ +/** + * Turning it off brings the interval back for good, and turning it on starts + * with the interval on, so an interval-off stored without it (a settings + * import) never takes effect. + */ internal fun applyAutoBackupOnChange(prefs: MutablePreferences, enabled: Boolean) { + if (!enabled || !prefs[SettingsKeys.autoBackupOnChange]) prefs[SettingsKeys.autoBackupScheduledStored] = true prefs[SettingsKeys.autoBackupOnChange] = enabled - if (!enabled) prefs[SettingsKeys.autoBackupScheduledStored] = true } /** diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlan.kt b/app/src/main/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlan.kt index 08b9c768..cbb4fb90 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlan.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlan.kt @@ -131,8 +131,10 @@ private val STAMP_FORMAT: DateTimeFormatter = DateTimeFormatter.ofPattern(STAMP_ * it, then one holding dated files under it; series that already write under * their id suffix keep that; with no claim at all the lowest id keeps the * name. The others take their id as a suffix until every name in the run is - * distinct. Ledger names gone from the folder ([existing], when known) claim - * nothing. A calendar named like the combined file is always suffixed. + * distinct. A stable copy a series outside the run still holds (a calendar + * taken out of the backup) is kept, so a calendar now named like it is + * suffixed too. Ledger names gone from the folder ([existing], when known) + * claim nothing. A calendar named like the combined file is always suffixed. */ fun backupTargets( calendars: List, @@ -150,14 +152,22 @@ fun backupTargets( val bases = calendars.associateTo(LinkedHashMap()) { it.id to safeFileName(it.displayName, MAX_BASE_BYTES, fallback = "calendar") } + val runKeys = calendars.map { latestLedgerKey(it.id.toString()) }.toSet() + val heldOutside = present.filterKeys { it.startsWith(LATEST_PREFIX) && it !in runKeys } + .values.flatten().map { it.lowercase() }.toSet() while (true) { val clashing = bases.entries.groupBy({ it.value.lowercase() }, { it.key }) .filter { (lower, ids) -> ids.size > 1 || lower == COMBINED_BACKUP_BASE.lowercase() } - if (clashing.isEmpty()) break - clashing.forEach { (lower, ids) -> - val keeper = if (lower == COMBINED_BACKUP_BASE.lowercase()) null else present.keeperOf(ids, bases) - ids.filter { it != keeper }.forEach { id -> bases[id] = "${bases.getValue(id)}-$id" } + if (clashing.isNotEmpty()) { + clashing.forEach { (lower, ids) -> + val keeper = if (lower == COMBINED_BACKUP_BASE.lowercase()) null else present.keeperOf(ids, bases) + ids.filter { it != keeper }.forEach { id -> bases[id] = "${bases.getValue(id)}-$id" } + } + continue } + val taken = bases.filterValues { latestFileName(it).lowercase() in heldOutside }.keys + if (taken.isEmpty()) break + taken.forEach { id -> bases[id] = "${bases.getValue(id)}-$id" } } return calendars.map { calendar -> BackupTarget( @@ -317,7 +327,10 @@ fun backupIntervalOn(stored: Boolean, onChange: Boolean): Boolean = stored || !o /** Without the interval there are no dated files, so every run only refreshes the stable copies. */ fun backupRunLatestOnly(changeRun: Boolean, intervalOn: Boolean): Boolean = changeRun || !intervalOn -/** Whether a run can back this series up at all: without dated files, only through its stable copy. */ +/** + * Whether a run can back this series up at all: without dated files, only + * through its stable copy, which a file of the user's can block. + */ fun BackupFilePlan.backedUp(intervalOn: Boolean): Boolean = intervalOn || latestName != null /** Closest offered retention count to [stored], so a stray value still shows a row. */ diff --git a/app/src/test/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefsTest.kt b/app/src/test/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefsTest.kt index 587add9f..1ca51f74 100644 --- a/app/src/test/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefsTest.kt +++ b/app/src/test/java/de/jeanlucmakiola/calendula/data/prefs/SettingsPrefsTest.kt @@ -5,6 +5,7 @@ import de.jeanlucmakiola.calendula.testSettings import de.jeanlucmakiola.floret.reminders.ReminderOverride import androidx.compose.ui.unit.dp +import androidx.datastore.preferences.core.booleanPreferencesKey import androidx.datastore.preferences.core.stringPreferencesKey import com.google.common.truth.Truth.assertThat import de.jeanlucmakiola.calendula.domain.CalendarSource @@ -982,6 +983,21 @@ class SettingsPrefsTest { assertThat(prefs.autoBackupScheduled.first()).isTrue() } + @Test + fun `an interval-off stored without after-change backups doesn't stick once they go on`(@TempDir tempDir: Path) = runTest { + val store = testDataStore(tempDir, "test_settings") + val prefs = SettingsPrefs(store) + store.updateData { p -> + val m = p.toMutablePreferences() + m[booleanPreferencesKey("auto_backup_scheduled")] = false + m + } + assertThat(prefs.autoBackupScheduled.first()).isTrue() + + assertThat(prefs.setAutoBackupOnChange(true)).isFalse() + assertThat(prefs.autoBackupScheduled.first()).isTrue() + } + @Test fun `a pre-411 install adopts its old file when the layout is pinned in place`(@TempDir tempDir: Path) = runTest { val store = testDataStore(tempDir, "test_settings") diff --git a/app/src/test/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlanTest.kt b/app/src/test/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlanTest.kt index 84f60b83..7817b709 100644 --- a/app/src/test/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlanTest.kt +++ b/app/src/test/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlanTest.kt @@ -107,6 +107,18 @@ class BackupPlanTest { .containsExactly("Fitness", "Fitness-20").inOrder() } + @Test + fun `a stable copy kept for a calendar out of the backup isn't taken over or left blocking`() { + val ledger = mapOf(latestLedgerKey("9") to listOf("Fitness.ics")) + val target = backupTargets(listOf(cal(20L, "Fitness")), combined = false, ledger, setOf("Fitness.ics")).single() + assertThat(target.baseName).isEqualTo("Fitness-20") + val plan = planBackupFiles(listOf(target), ledger, setOf("Fitness.ics"), at, keep = 3).single() + assertThat(plan.backedUp(intervalOn = false)).isTrue() + + val gone = backupTargets(listOf(cal(20L, "Fitness")), combined = false, ledger, existing = emptySet()).single() + assertThat(gone.baseName).isEqualTo("Fitness") + } + @Test fun `a calendar named like the combined file doesn't share its series`() { val target = backupTargets(listOf(cal(4L, COMBINED_BACKUP_BASE)), combined = false).single() diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index a37c68de..628e41ad 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -645,12 +645,15 @@ the app, is left to the next scheduled run. While the option is on, the interval itself can be switched off (`auto_backup_scheduled`, read through `backupIntervalOn`, so it never counts as off without the option): the periodic work is cancelled and no run writes or -prunes dated files. Run-now then rewrites every stable copy, change runs only -the changed ones, and a series whose stable name a file of the user's holds -counts as failed (not retried), since nothing else backs it up. Turning the -option off sets the interval back on, at the interval it had; any switch of the -interval backs up right away. What the text above leaves to the next scheduled -run then waits for the next run-now. +prunes dated files. Every run then rewrites only the stable copies that changed +or are missing from a complete listing (a change run checks for missing ones +even when no hash moved, since no scheduled run would restore them), and a +series whose stable name a file of the user's holds counts as failed (not +retried), since nothing else backs it up; a change run reports it again only +once its content changed. Turning the option on or off sets the interval back +on, at the interval it had; any switch of the interval backs up right away. +What the text above leaves to the next scheduled run then waits for the next +run-now. **A backup carries the series' deleted and moved occurrences.** `EXDATE` lives on the master row and is part of `EventExportProjection`; `IcsWriter` marks an From 830e48c5e7898bfa9234dbf56be0e287cdd8e7c8 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Wed, 25 Nov 2026 15:31:55 +0100 Subject: [PATCH 7/7] fix(#516): review round 4 - id suffix sticks, run-now rewrites every copy again, unchanged blocked series don't count as success --- .../calendula/data/backup/AutoBackup.kt | 26 +++++++++---------- .../calendula/domain/backup/BackupPlan.kt | 6 +++-- .../calendula/domain/backup/BackupPlanTest.kt | 8 ++++++ docs/ARCHITECTURE.md | 12 ++++----- docs/SETTINGS_BACKUP.md | 2 +- 5 files changed, 31 insertions(+), 23 deletions(-) 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 14835d9e..2852e9b7 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 @@ -279,7 +279,7 @@ class BackupWorker( * schedule and rewrites only the stable copies whose calendars changed. * With the interval off, no run writes dated files, so a series whose * stable name a file of the user's holds counts as failed (a change run - * only when its content changed), and run-now skips current copies too. + * only when its content changed). */ private suspend fun runBackup( deps: Deps, @@ -325,10 +325,12 @@ class BackupWorker( } else { emptyMap() } - // Unless a stable copy went missing: with the interval off, nothing else would restore it. + // With the interval off, unless a stable copy went missing: no scheduled run would restore it. + fun copyListed(target: BackupTarget) = latestFileName(target.baseName) in listing.files || + ledger[latestLedgerKey(target.key)].orEmpty().any { it in listing.files } if (changeRun && targets.all { preHashes[it.key].let { hash -> hash != null && hash == fingerprints[it.key] } } && - (!listing.complete || targets.all { latestFileName(it.baseName) in listing.files }) + (intervalOn || !listing.complete || targets.all(::copyListed)) ) { return RunOutcome.NothingToDo } @@ -404,6 +406,7 @@ class BackupWorker( var written = 0 var failed = 0 var blocked = 0 + var stillBlocked = 0 val landedLatest = mutableSetOf() for (plan in plans) { val target = plan.target @@ -419,8 +422,11 @@ class BackupWorker( // Its hash still goes on record, so a later change run can stop early. val blockedHash = hash ?: if (trackHashes) export(target)?.let { fingerprintOf(target, it) } else null blockedHash?.let { rememberBlocked(plan, it) } - // Reported once per content: a change run doesn't fail again on one that didn't change. - if (changeRun && hash == fingerprints[target.key]) continue + // A change run doesn't fail again on one that didn't change, nor report the run a success. + if (changeRun && hash == fingerprints[target.key]) { + stillBlocked++ + continue + } failed++ blocked++ continue @@ -437,14 +443,6 @@ class BackupWorker( } val fingerprint = fingerprintOf(target, text) if (!changeRun) rememberBlocked(plan, fingerprint) - // Without the interval, run-now leaves a stable copy that is already current alone. - if (!changeRun && latestOnly && trackHashes && plan.latestName in listing.files && - fingerprints[target.key] == fingerprint - ) { - landedLatest += target.key - written++ - continue - } val bytes = text.toByteArray(Charsets.UTF_8) // Not cancellable once a file exists: it must reach the ledger. withContext(NonCancellable) { @@ -468,7 +466,7 @@ class BackupWorker( } } return when { - failed == 0 && written == 0 -> RunOutcome.NothingToDo + failed == 0 && (written == 0 || stillBlocked > 0) -> RunOutcome.NothingToDo failed == 0 -> RunOutcome.Written written == 0 && failed == blocked -> RunOutcome.Blocked written == 0 -> RunOutcome.Failed diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlan.kt b/app/src/main/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlan.kt index cbb4fb90..dbed2c78 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlan.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlan.kt @@ -129,7 +129,7 @@ private val STAMP_FORMAT: DateTimeFormatter = DateTimeFormatter.ofPattern(STAMP_ * something follows shouldn't move because another calendar took the same * name. So the series holding the stable copy of the name in [ledger] keeps * it, then one holding dated files under it; series that already write under - * their id suffix keep that; with no claim at all the lowest id keeps the + * their id suffix keep that, clash or not; with no claim at all the lowest id keeps the * name. The others take their id as a suffix until every name in the run is * distinct. A stable copy a series outside the run still holds (a calendar * taken out of the backup) is kept, so a calendar now named like it is @@ -150,7 +150,9 @@ fun backupTargets( } val present = if (existing == null) ledger else ledger.mapValues { (_, names) -> names.filter { it in existing } } val bases = calendars.associateTo(LinkedHashMap()) { - it.id to safeFileName(it.displayName, MAX_BASE_BYTES, fallback = "calendar") + val base = safeFileName(it.displayName, MAX_BASE_BYTES, fallback = "calendar") + val suffixed = "$base-${it.id}" + it.id to if (present.holdsLatest(it.id.toString(), suffixed)) suffixed else base } val runKeys = calendars.map { latestLedgerKey(it.id.toString()) }.toSet() val heldOutside = present.filterKeys { it.startsWith(LATEST_PREFIX) && it !in runKeys } diff --git a/app/src/test/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlanTest.kt b/app/src/test/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlanTest.kt index 7817b709..1cf4b383 100644 --- a/app/src/test/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlanTest.kt +++ b/app/src/test/java/de/jeanlucmakiola/calendula/domain/backup/BackupPlanTest.kt @@ -119,6 +119,14 @@ class BackupPlanTest { assertThat(gone.baseName).isEqualTo("Fitness") } + @Test + fun `a series writing under its id suffix keeps it once the clash is gone`() { + val ledger = mapOf(latestLedgerKey("20") to listOf("Fitness-20.ics")) + val target = backupTargets(listOf(cal(20L, "Fitness")), combined = false, ledger, setOf("Fitness.ics", "Fitness-20.ics")) + .single() + assertThat(target.baseName).isEqualTo("Fitness-20") + } + @Test fun `a calendar named like the combined file doesn't share its series`() { val target = backupTargets(listOf(cal(4L, COMBINED_BACKUP_BASE)), combined = false).single() diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 628e41ad..7349f0ad 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -645,12 +645,12 @@ the app, is left to the next scheduled run. While the option is on, the interval itself can be switched off (`auto_backup_scheduled`, read through `backupIntervalOn`, so it never counts as off without the option): the periodic work is cancelled and no run writes or -prunes dated files. Every run then rewrites only the stable copies that changed -or are missing from a complete listing (a change run checks for missing ones -even when no hash moved, since no scheduled run would restore them), and a -series whose stable name a file of the user's holds counts as failed (not -retried), since nothing else backs it up; a change run reports it again only -once its content changed. Turning the option on or off sets the interval back +prunes dated files. Run-now then rewrites every stable copy, change runs the +changed ones and any missing from a complete listing (checked even when no hash +moved, since no scheduled run would restore them), and a series whose stable +name a file of the user's holds counts as failed (not retried), since nothing +else backs it up. A change run fails on it again only once its content changed, +and while it stays unchanged doesn't record the run as a success either. Turning the option on or off sets the interval back on, at the interval it had; any switch of the interval backs up right away. What the text above leaves to the next scheduled run then waits for the next run-now. diff --git a/docs/SETTINGS_BACKUP.md b/docs/SETTINGS_BACKUP.md index 4e0c9bf0..367a1cda 100644 --- a/docs/SETTINGS_BACKUP.md +++ b/docs/SETTINGS_BACKUP.md @@ -58,7 +58,7 @@ e.g. `"theme_mode": "DARK"`, `"multi_day_count": 4`, `"default_reminder_minutes": "10,60"`. Only keys that have been set are written. `SettingsBackupSchema.plain` lists them: appearance, fonts, views, the agenda screen, the event form and its default calendar, reminders -and the daily summary, automatic backup (switch, interval, layout, retention, +and the daily summary, automatic backup (switch, interval and whether it runs, layout, retention, backup on change) and contact special dates (switch, types, title templates, year).