Skip to content

Make backup retention configurable#21

Merged
StuartMeeks merged 1 commit into
masterfrom
feat/configurable-backup-retention
May 30, 2026
Merged

Make backup retention configurable#21
StuartMeeks merged 1 commit into
masterfrom
feat/configurable-backup-retention

Conversation

@StuartMeeks

Copy link
Copy Markdown
Owner

What

Surfaces backup retention as a user setting. Previously the "keep the last 20 backups" count was hard-coded at BackupService construction.

How

  • BackupService now reads retention lazily via a Func<int> provider instead of capturing a fixed int. Wired in Bootstrap to () => config.BackupRetention, so a change in Settings takes effect on the next write-triggered backup with no restart and no rebuilding of the DI singleton.
  • Provider values are clamped to at least 1 at prune time — a bad config value can never wipe all backups.
  • The fixed-int constructor is retained (delegates to the provider) so its eager >= 1 validation contract is unchanged.
  • AppConfig gains BackupRetention (default 20, via new DefaultBackupRetention const, which is now the single source of truth BackupService.DefaultRetention points at). Purely additive — no schema bump; old configs deserialise to the default.
  • SettingsViewModel gains a BackupRetention property (clamped, persisted) and the Settings page gains a "Backups to keep" NumberBox (1–200).

Tests

  • New BackupServiceTests: lazy provider is re-read on each prune; non-positive provider value clamps to 1; provider constructor rejects null.
  • All 109 Core tests pass.

Review

  • Independent codex exec review --base master: no correctness issues found.

Verification still owed (Windows)

Core is fully tested on Linux; the WinUI head (NumberBox binding, persistence across restart) wants a manual check on Windows: change "Backups to keep" to a small number, trigger several store writes, confirm pruning to that count and that the value survives a restart.

🤖 Generated with Claude Code

BackupService captured a fixed retention count at construction. It now
reads retention lazily via a Func<int> provider, wired in Bootstrap to
AppConfig.BackupRetention, so a change made in Settings takes effect on
the next write-triggered backup with no restart. Provider values are
clamped to at least 1 at prune time so a bad config never wipes backups.

Adds a "Backups to keep" NumberBox (1-200) to the Settings page and the
BackupRetention property/persistence on SettingsViewModel.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@StuartMeeks StuartMeeks merged commit 87ede8a into master May 30, 2026
4 checks passed
@StuartMeeks StuartMeeks deleted the feat/configurable-backup-retention branch May 30, 2026 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant