Skip to content

feat: add atomic file write utility and use it consistently#87

Merged
steve-calvert-glean merged 1 commit into
mainfrom
atomic-writes
Apr 12, 2026
Merged

feat: add atomic file write utility and use it consistently#87
steve-calvert-glean merged 1 commit into
mainfrom
atomic-writes

Conversation

@steve-calvert-glean
Copy link
Copy Markdown
Collaborator

Summary

  • Extracts the tmp+rename atomic write pattern from auth/storage.go into a shared fileutil.WriteFileAtomic utility
  • Updates session.Save(), config.saveToFile(), and auth.writeJSON() to use it
  • Prevents file corruption from crashes or power loss mid-write

Test plan

  • Unit test: write content, verify content and permissions
  • Unit test: no leftover tmp files after write
  • Unit test: non-existent directory returns error
  • Existing auth, config, and session tests pass
  • mise run test:all passes (453 tests, lint clean, binary builds)

@steve-calvert-glean steve-calvert-glean requested a review from a team as a code owner April 11, 2026 20:52
@steve-calvert-glean steve-calvert-glean added the enhancement New feature or request label Apr 12, 2026
Extract the tmp+rename atomic write pattern from auth/storage.go into
a shared fileutil.WriteFileAtomic function. Update session.Save(),
config.saveToFile(), and auth writeJSON() to use it, preventing file
corruption from crashes mid-write.
@steve-calvert-glean steve-calvert-glean merged commit 4c8b867 into main Apr 12, 2026
7 checks passed
@steve-calvert-glean steve-calvert-glean deleted the atomic-writes branch April 12, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants