Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c14775d4e5 | ||
|
|
47e737f8ec | ||
|
|
c4926145f3 | ||
|
|
770a4756a4 | ||
|
|
f14f6f32f4 |
No files matched your search
@@ -74,3 +74,4 @@ Gemfile.lock
|
||||
|
||||
# Claude Code
|
||||
/CLAUDE.md
|
||||
.kotlin/
|
||||
@@ -32,9 +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
|
||||
import de.jeanlucmakiola.calendula.domain.backup.inBackupOrder
|
||||
import de.jeanlucmakiola.calendula.domain.backup.latestHeldElsewhere
|
||||
@@ -78,8 +76,8 @@ object BackupScheduler {
|
||||
|
||||
/**
|
||||
* Reconcile the scheduled work with the saved settings: enqueue a unique
|
||||
* 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.
|
||||
* periodic request when backup is on and a folder is set, 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
|
||||
@@ -111,20 +109,16 @@ object BackupScheduler {
|
||||
stopWatching()
|
||||
return
|
||||
}
|
||||
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<BackupWorker>(interval, TimeUnit.MINUTES)
|
||||
.setInitialDelay(interval, TimeUnit.MINUTES)
|
||||
.build()
|
||||
workManager.enqueueUniquePeriodicWork(
|
||||
WORK_NAME,
|
||||
ExistingPeriodicWorkPolicy.UPDATE,
|
||||
request,
|
||||
)
|
||||
} else {
|
||||
workManager.cancelUniqueWork(WORK_NAME)
|
||||
}
|
||||
// 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<BackupWorker>(interval, TimeUnit.MINUTES)
|
||||
.setInitialDelay(interval, TimeUnit.MINUTES)
|
||||
.build()
|
||||
workManager.enqueueUniquePeriodicWork(
|
||||
WORK_NAME,
|
||||
ExistingPeriodicWorkPolicy.UPDATE,
|
||||
request,
|
||||
)
|
||||
if (!prefs.autoBackupOnChange.first()) {
|
||||
stopWatching()
|
||||
} else if (watchDropped || !BackupChangeJob.isPending(context)) {
|
||||
@@ -244,7 +238,7 @@ 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(), changeRun, prefs.autoBackupScheduled.first())
|
||||
runBackup(deps, prefs, folder.toUri(), latestOnly = changeRun)
|
||||
} catch (e: CancellationException) {
|
||||
throw e
|
||||
} catch (e: Exception) {
|
||||
@@ -267,28 +261,17 @@ class BackupWorker(
|
||||
return if (outcome == RunOutcome.Failed && !changeRun) Result.retry() else Result.success()
|
||||
}
|
||||
|
||||
/** [Blocked]: failed only on series no retry can back up, so it isn't retried. */
|
||||
private enum class RunOutcome { Written, PartlyFailed, Failed, Blocked, NothingToDo }
|
||||
private enum class RunOutcome { Written, PartlyFailed, Failed, 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 }
|
||||
|
||||
/**
|
||||
* Writes each series and prunes it only once its new file has landed. A
|
||||
* change run (#516) leaves the dated files and their retention to the
|
||||
* [latestOnly] 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 (a change run
|
||||
* only when its content changed).
|
||||
*/
|
||||
private suspend fun runBackup(
|
||||
deps: Deps,
|
||||
prefs: SettingsPrefs,
|
||||
folder: Uri,
|
||||
changeRun: Boolean,
|
||||
intervalOn: Boolean,
|
||||
): RunOutcome {
|
||||
val latestOnly = backupRunLatestOnly(changeRun, intervalOn)
|
||||
private suspend fun runBackup(deps: Deps, prefs: SettingsPrefs, folder: Uri, latestOnly: Boolean): RunOutcome {
|
||||
val repository = deps.repository()
|
||||
val exporter = deps.exporter()
|
||||
if (!applicationContext.hasPermission(Manifest.permission.READ_CALENDAR)) return RunOutcome.Failed
|
||||
@@ -320,18 +303,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<String, String?> = if (changeRun) {
|
||||
val preHashes: Map<String, String?> = if (latestOnly) {
|
||||
targets.associate { target -> target.key to export(target)?.let { fingerprintOf(target, it) } }
|
||||
} else {
|
||||
emptyMap()
|
||||
}
|
||||
// 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] } } &&
|
||||
(intervalOn || !listing.complete || targets.all(::copyListed))
|
||||
) {
|
||||
if (latestOnly && targets.all { preHashes[it.key].let { hash -> hash != null && hash == fingerprints[it.key] } }) {
|
||||
return RunOutcome.NothingToDo
|
||||
}
|
||||
val plans = planBackupFiles(
|
||||
@@ -405,36 +382,19 @@ class BackupWorker(
|
||||
|
||||
var written = 0
|
||||
var failed = 0
|
||||
var blocked = 0
|
||||
var stillBlocked = 0
|
||||
val landedLatest = mutableSetOf<String>()
|
||||
for (plan in plans) {
|
||||
val target = plan.target
|
||||
val hash = if (changeRun) {
|
||||
preHashes[target.key] ?: run {
|
||||
if (latestOnly) {
|
||||
val hash = preHashes[target.key] ?: run {
|
||||
failed++
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
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) }
|
||||
// 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++
|
||||
rememberBlocked(plan, hash)
|
||||
if (!plan.needsRefresh(hash, fingerprints, listing.files.keys, listing.complete)) {
|
||||
if (plan.latestName in listing.files) landedLatest += 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
|
||||
}
|
||||
// Read again rather than held since the pre-pass: one series' text in memory at a time.
|
||||
val text = export(target) ?: run {
|
||||
@@ -442,7 +402,7 @@ class BackupWorker(
|
||||
continue
|
||||
}
|
||||
val fingerprint = fingerprintOf(target, text)
|
||||
if (!changeRun) rememberBlocked(plan, fingerprint)
|
||||
if (!latestOnly) rememberBlocked(plan, fingerprint)
|
||||
val bytes = text.toByteArray(Charsets.UTF_8)
|
||||
// Not cancellable once a file exists: it must reach the ledger.
|
||||
withContext(NonCancellable) {
|
||||
@@ -466,9 +426,8 @@ class BackupWorker(
|
||||
}
|
||||
}
|
||||
return when {
|
||||
failed == 0 && (written == 0 || stillBlocked > 0) -> RunOutcome.NothingToDo
|
||||
failed == 0 && written == 0 -> RunOutcome.NothingToDo
|
||||
failed == 0 -> RunOutcome.Written
|
||||
written == 0 && failed == blocked -> RunOutcome.Blocked
|
||||
written == 0 -> RunOutcome.Failed
|
||||
else -> RunOutcome.PartlyFailed
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ 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
|
||||
@@ -129,12 +128,7 @@ class SettingsBackupEngine @Inject constructor(
|
||||
}
|
||||
}
|
||||
step("reminders") { reminderScanner.scan() }
|
||||
step("auto backup") {
|
||||
BackupScheduler.reconcile(context, settingsPrefs)
|
||||
// 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)
|
||||
}
|
||||
step("auto backup") { BackupScheduler.reconcile(context, settingsPrefs) }
|
||||
plan.launcherName?.let { name ->
|
||||
step("launcher name") { if (launcherNames.current() != name) launcherNames.set(name) }
|
||||
}
|
||||
|
||||
@@ -64,7 +64,6 @@ internal object SettingsBackupSchema {
|
||||
SettingsKeys.autoBackupCombinedStored,
|
||||
SettingsKeys.autoBackupKeep,
|
||||
SettingsKeys.autoBackupOnChange,
|
||||
SettingsKeys.autoBackupScheduledStored,
|
||||
SettingsKeys.specialDatesEnabled,
|
||||
SettingsKeys.specialDatesShowYear,
|
||||
) + SettingsKeys.specialDateTypeEnabled.values + SettingsKeys.specialDatesTitleTemplate.values
|
||||
|
||||
@@ -9,7 +9,6 @@ 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
|
||||
@@ -230,11 +229,6 @@ class SettingsPrefs @Inject constructor(
|
||||
val autoBackupKeep: Flow<Int> = prefs.flow(SettingsKeys.autoBackupKeep)
|
||||
val autoBackupLedger: Flow<BackupLedger> = prefs.flow(SettingsKeys.autoBackupLedger)
|
||||
val autoBackupOnChange: Flow<Boolean> = prefs.flow(SettingsKeys.autoBackupOnChange)
|
||||
val autoBackupScheduled: Flow<Boolean> = prefs.snapshot { it.autoBackupScheduled }
|
||||
|
||||
/** Read together, so the screen never shows one updated without the other. */
|
||||
val autoBackupOnChangeAndScheduled: Flow<Pair<Boolean, Boolean>> =
|
||||
prefs.snapshot { it[SettingsKeys.autoBackupOnChange] to it.autoBackupScheduled }
|
||||
val autoBackupFingerprints: Flow<BackupFingerprints> = prefs.flow(SettingsKeys.autoBackupFingerprints)
|
||||
val specialDatesEnabled: Flow<Boolean> = prefs.flow(SettingsKeys.specialDatesEnabled)
|
||||
val specialDatesTypes: Flow<Set<SpecialDateType>> = prefs.snapshot { it.specialDatesTypes }
|
||||
@@ -529,28 +523,7 @@ class SettingsPrefs @Inject constructor(
|
||||
|
||||
suspend fun setAutoBackupKeep(keep: Int) = prefs.set(SettingsKeys.autoBackupKeep, keep)
|
||||
|
||||
/** 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]. 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
|
||||
}
|
||||
suspend fun setAutoBackupOnChange(enabled: Boolean) = prefs.set(SettingsKeys.autoBackupOnChange, enabled)
|
||||
|
||||
/**
|
||||
* Atomic, so a run's ledger writes never undo one made meanwhile (pinning
|
||||
@@ -1075,9 +1048,6 @@ object SettingsKeys {
|
||||
/** Whether a change to a backed-up calendar also refreshes the stable copies (#516). Opt-in. */
|
||||
val autoBackupOnChange: Pref<Boolean> = booleanPref("auto_backup_on_change", false)
|
||||
|
||||
/** Whether the dated backups run on the interval; read as [Preferences.autoBackupScheduled]. */
|
||||
val autoBackupScheduledStored: Pref<Boolean> = booleanPref("auto_backup_scheduled", true)
|
||||
|
||||
/** Content hash of each series' stable copy, so a change run skips untouched ones (#516). */
|
||||
val autoBackupFingerprints: Pref<BackupFingerprints> =
|
||||
nullableStringPref("auto_backup_fingerprints").map(::parseBackupFingerprints, ::persistBackupFingerprints)
|
||||
@@ -1137,20 +1107,6 @@ val Preferences.autoBackupSelection: BackupSelection
|
||||
excluded = this[SettingsKeys.autoBackupExcluded],
|
||||
)
|
||||
|
||||
/** Whether the dated backups run on the interval; see [backupIntervalOn]. */
|
||||
val Preferences.autoBackupScheduled: Boolean
|
||||
get() = backupIntervalOn(this[SettingsKeys.autoBackupScheduledStored], this[SettingsKeys.autoBackupOnChange])
|
||||
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
@@ -129,12 +129,10 @@ 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, clash or not; with no claim at all the lowest id keeps the
|
||||
* 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. 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.
|
||||
* distinct. 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<CalendarSource>,
|
||||
@@ -150,26 +148,16 @@ fun backupTargets(
|
||||
}
|
||||
val present = if (existing == null) ledger else ledger.mapValues { (_, names) -> names.filter { it in existing } }
|
||||
val bases = calendars.associateTo(LinkedHashMap()) {
|
||||
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
|
||||
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.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
|
||||
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" }
|
||||
}
|
||||
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(
|
||||
@@ -323,18 +311,6 @@ 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
|
||||
|
||||
/**
|
||||
* 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. */
|
||||
fun normalizeBackupKeep(stored: Int): Int =
|
||||
BACKUP_KEEP_OPTIONS.minBy { kotlin.math.abs(it - stored) }
|
||||
@@ -393,7 +369,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 next run that isn't a change run.
|
||||
* add a duplicate beside it, so that is left to the scheduled run.
|
||||
*/
|
||||
fun BackupFilePlan.needsRefresh(
|
||||
fingerprint: String,
|
||||
|
||||
@@ -371,29 +371,13 @@ private fun BackupContent(
|
||||
)
|
||||
GroupedRow(
|
||||
title = stringResource(R.string.calendars_auto_backup_interval),
|
||||
summary = if (autoBackup.scheduled) {
|
||||
backupIntervalLabel(autoBackup.intervalMinutes)
|
||||
} else {
|
||||
stringResource(R.string.calendars_auto_backup_interval_off)
|
||||
},
|
||||
summary = backupIntervalLabel(autoBackup.intervalMinutes),
|
||||
position = Position.Middle,
|
||||
// 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) }),
|
||||
onClick = onEditInterval,
|
||||
)
|
||||
GroupedSwitchRow(
|
||||
title = stringResource(R.string.calendars_auto_backup_on_change),
|
||||
summary = stringResource(
|
||||
if (autoBackup.scheduled) {
|
||||
R.string.calendars_auto_backup_on_change_summary
|
||||
} else {
|
||||
R.string.calendars_auto_backup_on_change_only_summary
|
||||
},
|
||||
),
|
||||
summary = stringResource(R.string.calendars_auto_backup_on_change_summary),
|
||||
checked = autoBackup.onChange,
|
||||
onCheckedChange = viewModel::setAutoBackupOnChange,
|
||||
position = Position.Middle,
|
||||
@@ -420,17 +404,14 @@ private fun BackupContent(
|
||||
),
|
||||
checked = autoBackup.combined,
|
||||
onCheckedChange = viewModel::setAutoBackupCombined,
|
||||
position = if (autoBackup.scheduled) Position.Middle else Position.Bottom,
|
||||
position = Position.Middle,
|
||||
)
|
||||
GroupedRow(
|
||||
title = stringResource(R.string.calendars_auto_backup_keep),
|
||||
summary = backupKeepLabel(autoBackup.keep),
|
||||
position = Position.Bottom,
|
||||
onClick = onEditKeep,
|
||||
)
|
||||
// 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)
|
||||
|
||||
@@ -109,9 +109,9 @@ class CalendarsViewModel @Inject constructor(
|
||||
settingsPrefs.autoBackupSelection,
|
||||
settingsPrefs.autoBackupCombined,
|
||||
settingsPrefs.autoBackupKeep,
|
||||
settingsPrefs.autoBackupOnChangeAndScheduled,
|
||||
) { base, selection, combined, keep, (onChange, scheduled) ->
|
||||
base.copy(selection = selection, combined = combined, keep = keep, onChange = onChange, scheduled = scheduled)
|
||||
settingsPrefs.autoBackupOnChange,
|
||||
) { base, selection, combined, keep, onChange ->
|
||||
base.copy(selection = selection, combined = combined, keep = keep, onChange = onChange)
|
||||
}
|
||||
.flowOn(io)
|
||||
.stateWhileSubscribed(
|
||||
@@ -296,21 +296,8 @@ class CalendarsViewModel @Inject constructor(
|
||||
|
||||
fun setAutoBackupOnChange(enabled: Boolean) {
|
||||
viewModelScope.launch {
|
||||
val switched = settingsPrefs.setAutoBackupOnChange(enabled)
|
||||
settingsPrefs.setAutoBackupOnChange(enabled)
|
||||
reschedule()
|
||||
if (switched) runBackupIfActive()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 switched = settingsPrefs.setAutoBackupScheduled(enabled)
|
||||
reschedule()
|
||||
if (switched) runBackupIfActive()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,7 +356,6 @@ 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. */
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.jeanlucmakiola.calendula.ui.common
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ColumnScope
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
@@ -131,7 +132,8 @@ fun FixedTimeReminderEditor(
|
||||
* Picker for a fixed-time default (#459), full-screen: off, or a reminder at a
|
||||
* set time edited in place — and, on a per-calendar picker ([inheritedLabel]
|
||||
* non-null), deferring to the global default, [inherited], which also seeds the
|
||||
* editor. Applies live; the user leaves via back.
|
||||
* editor. Applies live; the user leaves via back, or through [footer], which
|
||||
* follows the options and gets [onDismiss].
|
||||
*/
|
||||
@Composable
|
||||
fun FixedTimeReminderPicker(
|
||||
@@ -141,6 +143,7 @@ fun FixedTimeReminderPicker(
|
||||
onDismiss: () -> Unit,
|
||||
inheritedLabel: String? = null,
|
||||
inherited: FixedTimeReminder? = null,
|
||||
footer: @Composable ColumnScope.(dismiss: () -> Unit) -> Unit = {},
|
||||
) {
|
||||
var current by rememberSaveable(stateSaver = FixedTimeOverrideSaver) { mutableStateOf(selected) }
|
||||
var editing by rememberSaveable { mutableStateOf(false) }
|
||||
@@ -192,6 +195,7 @@ fun FixedTimeReminderPicker(
|
||||
},
|
||||
)
|
||||
}
|
||||
footer(onDismiss)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import de.jeanlucmakiola.floret.identity.collapseExit
|
||||
import de.jeanlucmakiola.floret.identity.expandEnter
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.EnterExitState
|
||||
import android.Manifest
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
@@ -19,10 +20,13 @@ import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.relocation.BringIntoViewRequester
|
||||
import androidx.compose.foundation.relocation.bringIntoViewRequester
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
|
||||
import androidx.compose.material.icons.automirrored.filled.OpenInNew
|
||||
import androidx.compose.material.icons.outlined.Info
|
||||
import androidx.compose.material.icons.outlined.NotificationsActive
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
@@ -108,6 +112,7 @@ internal fun NotificationsScreen(
|
||||
var showFixedDefault by remember { mutableStateOf(false) }
|
||||
var showDigestDay by remember { mutableStateOf(false) }
|
||||
var showDigestTime by remember { mutableStateOf(false) }
|
||||
var revealDigest by rememberSaveable { mutableStateOf(false) }
|
||||
val scope = rememberCoroutineScope()
|
||||
val channelStatus by viewModel.channelStatus.collectAsStateWithLifecycle()
|
||||
val digestBlocked by viewModel.digestBlocked.collectAsStateWithLifecycle()
|
||||
@@ -193,9 +198,14 @@ internal fun NotificationsScreen(
|
||||
|
||||
Spacer(Modifier.height(24.dp))
|
||||
DailyDigestRows(
|
||||
reveal = revealDigest,
|
||||
onRevealed = { revealDigest = false },
|
||||
digest = state.dailyDigest,
|
||||
blocked = channelStatus.appBlocked || digestBlocked,
|
||||
onEnable = toggleDigest,
|
||||
onEnable = {
|
||||
revealDigest = false
|
||||
toggleDigest(it)
|
||||
},
|
||||
onPickDay = { showDigestDay = true },
|
||||
onPickTime = { showDigestTime = true },
|
||||
onOpenSound = {
|
||||
@@ -257,6 +267,29 @@ internal fun NotificationsScreen(
|
||||
selected = state.defaultFixedTimeReminder?.let { FixedTimeOverride.At(it) } ?: FixedTimeOverride.Off,
|
||||
onSelect = { viewModel.setDefaultFixedTimeReminder((it as? FixedTimeOverride.At)?.reminder) },
|
||||
onDismiss = { showFixedDefault = false },
|
||||
footer = { dismiss ->
|
||||
// For those after one list of the day's events (#459).
|
||||
if (!state.dailyDigest.enabled) {
|
||||
Spacer(Modifier.height(24.dp))
|
||||
GroupedRow(
|
||||
title = stringResource(R.string.settings_digest_turn_on),
|
||||
summary = stringResource(R.string.settings_digest_hint),
|
||||
position = Position.Alone,
|
||||
leading = {
|
||||
Icon(
|
||||
imageVector = Icons.Outlined.NotificationsActive,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
revealDigest = true
|
||||
toggleDigest(true)
|
||||
dismiss()
|
||||
},
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
if (showDigestDay) {
|
||||
@@ -328,7 +361,8 @@ internal fun NotificationsScreen(
|
||||
|
||||
/**
|
||||
* The daily summary (#459): its switch, and once on, which day it lists, when,
|
||||
* and its channel's system settings.
|
||||
* and its channel's system settings. With [reveal], the block scrolls into view
|
||||
* once those rows have expanded, then reports [onRevealed].
|
||||
*/
|
||||
@Composable
|
||||
private fun DailyDigestRows(
|
||||
@@ -338,47 +372,59 @@ private fun DailyDigestRows(
|
||||
onPickDay: () -> Unit,
|
||||
onPickTime: () -> Unit,
|
||||
onOpenSound: () -> Unit,
|
||||
reveal: Boolean,
|
||||
onRevealed: () -> Unit,
|
||||
) {
|
||||
GroupedSwitchRow(
|
||||
title = stringResource(R.string.settings_digest),
|
||||
checked = digest.enabled,
|
||||
onCheckedChange = onEnable,
|
||||
summary = if (digest.enabled) {
|
||||
stringResource(
|
||||
R.string.settings_digest_summary,
|
||||
stringResource(digestDayLabel(digest.day)),
|
||||
settingsTimeOfDay(digest.timeMinutes),
|
||||
)
|
||||
} else {
|
||||
stringResource(R.string.settings_digest_hint)
|
||||
},
|
||||
position = if (digest.enabled) Position.Top else Position.Alone,
|
||||
)
|
||||
AnimatedVisibility(visible = digest.enabled, enter = expandEnter(), exit = collapseExit()) {
|
||||
Column {
|
||||
GroupedRow(
|
||||
title = stringResource(R.string.settings_digest_day),
|
||||
summary = stringResource(digestDayLabel(digest.day)),
|
||||
position = Position.Middle,
|
||||
onClick = onPickDay,
|
||||
)
|
||||
GroupedRow(
|
||||
title = stringResource(R.string.settings_digest_time),
|
||||
summary = settingsTimeOfDay(digest.timeMinutes),
|
||||
position = Position.Middle,
|
||||
onClick = onPickTime,
|
||||
)
|
||||
GroupedRow(
|
||||
title = stringResource(R.string.settings_notification_sound),
|
||||
summary = if (blocked) {
|
||||
stringResource(R.string.settings_notifications_blocked_hint)
|
||||
} else {
|
||||
stringResource(R.string.settings_digest_sound_hint)
|
||||
},
|
||||
position = Position.Bottom,
|
||||
trailing = { ExternalLinkIcon() },
|
||||
onClick = onOpenSound,
|
||||
)
|
||||
val requester = remember { BringIntoViewRequester() }
|
||||
Column(Modifier.bringIntoViewRequester(requester)) {
|
||||
GroupedSwitchRow(
|
||||
title = stringResource(R.string.settings_digest),
|
||||
checked = digest.enabled,
|
||||
onCheckedChange = onEnable,
|
||||
summary = if (digest.enabled) {
|
||||
stringResource(
|
||||
R.string.settings_digest_summary,
|
||||
stringResource(digestDayLabel(digest.day)),
|
||||
settingsTimeOfDay(digest.timeMinutes),
|
||||
)
|
||||
} else {
|
||||
stringResource(R.string.settings_digest_hint)
|
||||
},
|
||||
position = if (digest.enabled) Position.Top else Position.Alone,
|
||||
)
|
||||
AnimatedVisibility(visible = digest.enabled, enter = expandEnter(), exit = collapseExit()) {
|
||||
val settled = !transition.isRunning && transition.currentState == EnterExitState.Visible
|
||||
LaunchedEffect(settled, reveal) {
|
||||
if (settled && reveal) {
|
||||
requester.bringIntoView()
|
||||
onRevealed()
|
||||
}
|
||||
}
|
||||
Column {
|
||||
GroupedRow(
|
||||
title = stringResource(R.string.settings_digest_day),
|
||||
summary = stringResource(digestDayLabel(digest.day)),
|
||||
position = Position.Middle,
|
||||
onClick = onPickDay,
|
||||
)
|
||||
GroupedRow(
|
||||
title = stringResource(R.string.settings_digest_time),
|
||||
summary = settingsTimeOfDay(digest.timeMinutes),
|
||||
position = Position.Middle,
|
||||
onClick = onPickTime,
|
||||
)
|
||||
GroupedRow(
|
||||
title = stringResource(R.string.settings_notification_sound),
|
||||
summary = if (blocked) {
|
||||
stringResource(R.string.settings_notifications_blocked_hint)
|
||||
} else {
|
||||
stringResource(R.string.settings_digest_sound_hint)
|
||||
},
|
||||
position = Position.Bottom,
|
||||
trailing = { ExternalLinkIcon() },
|
||||
onClick = onOpenSound,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -808,6 +808,7 @@
|
||||
<string name="settings_fixed_reminder_hint">Added to new timed events, e.g. the evening before. It follows the event when you move it to another time.</string>
|
||||
<!-- Daily summary notification (#459) -->
|
||||
<string name="settings_digest">Daily summary</string>
|
||||
<string name="settings_digest_turn_on">Turn on daily summary</string>
|
||||
<string name="settings_digest_hint">One notification listing a day\'s events</string>
|
||||
<!-- %1$s is settings_digest_day_today/tomorrow, %2$s a clock time. -->
|
||||
<string name="settings_digest_summary">%1$s at %2$s</string>
|
||||
@@ -1034,10 +1035,8 @@
|
||||
<string name="calendars_auto_backup_interval">Interval</string>
|
||||
<string name="calendars_auto_backup_every">Every %1$s</string>
|
||||
<string name="calendars_auto_backup_interval_min">Minimum 30 minutes.</string>
|
||||
<string name="calendars_auto_backup_interval_off">Off, only after changes</string>
|
||||
<string name="calendars_auto_backup_on_change">Also back up after changes</string>
|
||||
<string name="calendars_auto_backup_on_change_summary">Updates the undated copy a few minutes after events change. Dated backups stay on the interval.</string>
|
||||
<string name="calendars_auto_backup_on_change_only_summary">Updates the undated copy a few minutes after events change. No dated backups.</string>
|
||||
<string name="calendars_auto_backup_calendars">Calendars</string>
|
||||
<plurals name="calendars_auto_backup_calendars_count">
|
||||
<item quantity="one">%d calendar</item>
|
||||
|
||||
@@ -5,7 +5,6 @@ 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
|
||||
@@ -933,71 +932,6 @@ 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 `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)
|
||||
prefs.setAutoBackupScheduled(false)
|
||||
|
||||
prefs.setAutoBackupOnChange(true)
|
||||
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")
|
||||
|
||||
@@ -107,26 +107,6 @@ 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 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()
|
||||
@@ -422,30 +402,4 @@ 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()
|
||||
}
|
||||
|
||||
@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()
|
||||
}
|
||||
}
|
||||
+1
-14
@@ -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, or fails to, is recorded on the status line; the failure notification comes once
|
||||
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
|
||||
@@ -642,19 +642,6 @@ 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 no run writes or
|
||||
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.
|
||||
|
||||
**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
|
||||
|
||||
@@ -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 and whether it runs, layout, retention,
|
||||
and the daily summary, automatic backup (switch, interval, layout, retention,
|
||||
backup on change) and contact special dates (switch, types, title
|
||||
templates, year).
|
||||
|
||||
|
||||
Reference in new issue
Block a user