Repository navigation
fix(db): eliminate redundant restore snapshot staging and ensure temp cleanup - #1193
Merged
Merged
Conversation
Contributor
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced Oct 17, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Eliminate redundant restore snapshot staging and ensure temp directory cleanup for FloCafe issue #1175
What Changed
materializeRestoreSourceinmain/db.tsto return an explicit cleanup callback and clean up its temp directory immediately on write errors, replacing uncoordinatedsetImmediatecleanup.dataOnlyRestoreand managed the snapshot lifecycle inrestoreBackupwith atry...finallyblock to ensure temp directories are cleaned up across all restore paths.tests/backup-restore-production.test.tsverifying single-snapshot staging and temp directory removal across direct, data-only, rejected, and failed-materialization restore flows.Risk Assessment
✅ Low: The change is tightly bounded to staging and cleaning temporary restore snapshots and is well-covered by targeted regression tests.
Testing
Driven 4 live end-to-end scenarios against the running FloCafe Express API server and SQLite database engine in an isolated environment, confirming elimination of duplicate snapshot staging during cross-version restore and verifying 100% temporary staging directory cleanup with zero leaks across all success, rejection, and write-failure paths.
Evidence: Live Product Verification Summary
Markdown executive summary of the 4 live product scenarios driven against the running FloCafe Express API server and SQLite database engine, confirming 0 leaked staging directories.Evidence: Scenario 1: Direct Restore Evidence
HTTP request and response transcript, database reversion verification, and single-staging directory cleanup confirmation for matching-version full database restore.Evidence: Scenario 2: Data-Only Restore Deduplication Evidence
HTTP response showing data_only mode, verification that exactly 1 staging snapshot was created (Issue #1175 duplicate staging eliminated), and immediate temp cleanup upon return.Evidence: Scenario 3: Safely Rejected Restore Cleanup Evidence
HTTP 422 rejection response and verification that the staged snapshot directory was cleaned up in the finally block with 0 directory leaks.Evidence: Scenario 4: Materialization Write Failure Cleanup Evidence
Injected write failure handling proving that materializeRestoreSource catch block deletes the mkdtempSync directory immediately before rethrowing.Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
node tests/run-electron-node-test.cjs tests/backup-restore-production.test.tsnode tests/run-electron-node-test.cjs tests/restore-from-file-api.test.tsnode tests/run-electron-node-test.cjs tests/restore-safety-copy.test.tsnode tests/run-electron-node-test.cjs scratch/live-restore-scenarios.cjs(live Express API and SQLite engine standup, driving POST /api/db/restore across matching schema, mismatched schema, FK corruption rejection, and I/O write failure scenarios)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.