Skip to content

feat: relocate vault backups to a managed folder with retention cap - #5

Merged
GFrancV merged 4 commits into
mainfrom
feat/backup-storage-relocation
Jul 21, 2026
Merged

feat: relocate vault backups to a managed folder with retention cap#5
GFrancV merged 4 commits into
mainfrom
feat/backup-storage-relocation

Conversation

@GFrancV

@GFrancV GFrancV commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds src/main/vault/backups.ts: vault backups now live under userData/vault-backups/<sha256-of-vault-path>/ instead of being dropped next to the vault file forever, with a hardcoded retention cap (MAX_BACKUPS_PER_VAULT = 3 — oldest deleted first by mtime).
  • confirmMigrationAndBackup (the shared helper from feat: add SQL schema version guard with migration confirmation parity #4) now calls createVaultBackup instead of an inline copyFileSync, so both header-version and schema-version migration backups land in the new location with descriptive names (<reason>-v<from>-to-v<to>-<timestamp>.nvx).
  • Adds a "Open backups folder" button in Security settings, replacing the "Vault format" section — that section's manual "Upgrade vault format" action (a toast telling you to close/reopen the vault) is now dead code superseded by the automatic migration dialog from feat: add SQL schema version guard with migration confirmation parity #4/feat: relocate vault backups to a managed folder with retention cap #5, so it — and its only consumer, the useVaultCapabilities hook — are removed.
  • Bug fix found during manual testing: vault:migration-confirmed/vault:migration-cancelled were synchronously nulling migrationBackupTimestamp right after resolving the pending migration promise. Since resolving a promise only schedules its continuation as a microtask (it doesn't run inline), this reset was winning the race every time — meaning the "create a backup" checkbox has silently never actually created a backup, since the confirmation dialog was wired up in feat: add SQL schema version guard with migration confirmation parity #4. Fixed by leaving the reset to the code that actually reads the flag.

Test plan

  • Manual test via pnpm dev: triggered a schema migration with the backup checkbox checked — confirmed (after the race-condition fix) the backup file lands under %APPDATA%\Notvex Dev\vault-backups\<hash>\ with the new naming.
  • "Open backups folder" with no backups yet → toast.error("No backups yet."), no explorer opens.
  • "Open backups folder" after a backup exists → OS file explorer opens on the correct folder.
  • Retention-trimming algorithm (keep 3 newest by mtime, delete the rest) verified in isolation with a throwaway script against 5 dummy files — logic matches createVaultBackup exactly.
  • pnpm validate passes.

@github-actions

Copy link
Copy Markdown

React Doctor found no issues. 🎉

⚠️ Warning: .github/workflows/react-doctor.yml is configured incorrectly. See below to fix.

React Doctor compares against main to report only the issues this pull request introduces. This run couldn't complete that comparison (usually a shallow CI checkout with no merge base), so it listed every issue in the changed files, including ones that already existed on main.

Add fetch-depth: 0 to the actions/checkout step in .github/workflows/react-doctor.yml so the checkout includes the history React Doctor needs:

 jobs:
   react-doctor:
     steps:
       - uses: actions/checkout@v5
+        with:
+          fetch-depth: 0

       - uses: millionco/react-doctor@v2

To silence this warning, set silence-missing-baseline-warning: true on the React Doctor action.

Reviewed by React Doctor for commit 8aed0b2.

@GFrancV
GFrancV merged commit 54431aa into main Jul 21, 2026
3 checks passed
@GFrancV
GFrancV deleted the feat/backup-storage-relocation branch July 21, 2026 14:32
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