Repository navigation
Save files atomically and allow larger trusted replay recordings - #157
Merged
Merged
Conversation
Atomic replacement gave TUI exports tempfile's 0600 mode, so a session exported under sudo was unreadable by the invoking user, and replacing a symlinked preferences file swapped the link for a regular file. Exports now get the usual 0666 & umask; preferences stay 0600. An existing symlink is resolved so the link's target is replaced instead.
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.
Preferences and TUI JSON exports truncate the previous destination before writing, so a failed write can destroy a valid save. Long recordings also exceed replay's fixed 10 MiB cap with no way to open them.
Write buffered content to a private temporary file beside the destination, sync it, then atomically replace the old file using tempfile's cross-platform persist operation. Errors and unwinding remove the temporary file and leave the previous contents intact. Preference files retain Unix 0600 permissions; successful saves keep the existing filenames and JSON schema.
Keep the default 10 MiB replay/diff limit, add
--replay-size-limit <MiB>(1–1024) for larger trusted recordings, and enforce the bound while reading as well as checking metadata. Errors explain how to raise the limit. Exports retain the complete event history.Validation: full build/tests/clippy/fmt/doc checks and Rust 1.88 all-target check pass. Tests cover partial-write failure, failed replacement, interrupted serialization, temporary-file cleanup, preference permissions and repeated JSON replacement. An end-to-end test exports 100,000 genuine probe events above 10 MiB, confirms default rejection, then replays every event and diffs the recording successfully with an explicit limit. Reader tests cover exact boundaries, extra bytes and malformed JSON. Tests use isolated directories and never touch user preferences.
Dependency: tempfile 3.27 was already present in Cargo.lock through the test dependencies; this adds it as a production dependency without changing any locked versions. The atomic publish syncs the file first; filesystem-wide power-loss guarantees are outside this change.
Integration validation: all fourteen draft branches (#144–#157) merge cleanly together. The combined build, tests (including the large-recording CLI test), clippy, formatting, documentation and Rust 1.88 all-target check pass locally.