fix(#516): keep a blocked series' hash, back up when a settings restore switches the interval

This commit is contained in:
makiolaj committed 2026-11-25 12:16:32 +01:00
1 parent 242ccd3b70
commit 732548a989
3 files changed
+21 -12

No files matched your search

@@ -402,21 +402,24 @@ class BackupWorker(
val landedLatest = mutableSetOf<String>()
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 {
@@ -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) }
}
+1 -1
View File
@@ -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