Repository navigation
Conversation
Keep the previous file when a write, close, or rename fails. Replace it through os_safe_replace only after a successful close, instead of deleting it before renaming the temporary file. Add Linux regressions for failures and successful replacement.
Member
zackees
added a commit
that referenced
this pull request
Oct 10, 2026
Safely serialize to a temporary file symlinked to /dev/full, or whose rename fails: an immediate write error, a buffered flush error and a failed replacement must each leave the original file intact, and a successful save must replace it and remove the temporary file. The tests live beside the unchanged test_file_serializer characterization test, Linux-only for /dev/full. Rebased from #36 onto current master. Co-Authored-By: Mquarmoc <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Description
Check stream errors and the close result before installing a safely serialized file. Reuse
os_safe_replacerather than unlinking the destination before renaming the temporary file, and log failed saves.Motivation and Context
The old safe-save cleanup could install an incomplete temporary file after a write/flush failure. It also deleted the destination before attempting rename, losing the old file if rename failed. Four new C tests cover immediate write errors, buffered flush errors, replacement failure, and successful replacement. The public API stays unchanged.
How Has This Been Tested?
The new failure cases were run against the original implementation and failed before the fix. The complete repository
./lintand./unittestcommands pass independently on this branch (Ubuntu 24.04 WSL host, Ubuntu 26.04 validation container):ENABLE_RUST_LIBOBS=OFFandON.The new filesystem failure tests are Linux-only because they use
/dev/full. Windows/macOS and an interactive OBS session were not run locally. These fixes detect buffered write errors; they do not add power-loss durability.Types of changes
Checklist: