Skip to content

fix: prevent database loss when disk is full - #692

Merged
replydev merged 1 commit into
mainfrom
fix/691-prevent-data-loss-on-full-disk
Oct 21, 2026
Merged

replydev merged 1 commit into
mainfrom
fix/691-prevent-data-loss-on-full-disk

Conversation

@replydev

Copy link
Copy Markdown
Owner

Database saves previously truncated the existing database before writing its replacement, so running out of disk space could destroy all stored OTPs.

Write and sync the encrypted replacement to a temporary file in the same directory, then atomically replace the database. Preserve existing permissions and symlink targets, clean up temporary files on failure, and include the underlying error in save failures. Only clear the modified flag after a successful save.

Add regression coverage for failed writes, successful replacement, permissions, and symlinks. A CLI test forces a partial write failure and verifies the original database is unchanged and its OTP remains readable. Existing add tests now use isolated database copies.

Closes #691.

Validation:

  • cargo test --locked — 50 tests passed
  • cargo test --locked --release — 50 tests passed
  • cargo fmt --all -- --check
  • cargo clippy -- -D warnings

@replydev
replydev merged commit 3c4e17e into main Oct 21, 2026
9 checks passed
@replydev
replydev deleted the fix/691-prevent-data-loss-on-full-disk branch October 21, 2026 18:59
cotp-release-bot Bot pushed a commit that referenced this pull request Oct 21, 2026
## [1.10.1](v1.10.0...v1.10.1) (2026-10-21)

### Bug Fixes

* prevent database loss when disk is full ([197c877](197c877))
* prevent database loss when disk is full ([#692](#692)) ([3c4e17e](3c4e17e))
@cotp-release-bot

Copy link
Copy Markdown

🎉 This PR is included in version 1.10.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lack of free space causes full data loss

1 participant