Skip to content

Use atomic tmp-then-rename writes in cache#62

Merged
ferronn-dev merged 3 commits into
mainfrom
claude/atomic-cache-writes-DSx9L
May 18, 2026
Merged

Use atomic tmp-then-rename writes in cache#62
ferronn-dev merged 3 commits into
mainfrom
claude/atomic-cache-writes-DSx9L

Conversation

@ferronn-dev

@ferronn-dev ferronn-dev commented Apr 10, 2026

Copy link
Copy Markdown
Member

Summary

  • Modify writeall() in tactless.c to write cache data to a .tmp file first, then atomically rename() it to the final path
  • On any failure (open, write, close, rename), the .tmp file is cleaned up with remove()

This ensures readers never observe a partially-written cache file.

@ferronn-dev ferronn-dev force-pushed the claude/atomic-cache-writes-DSx9L branch from e34ba9e to 2faeb25 Compare April 10, 2026 03:34
claude added 3 commits May 17, 2026 21:52
Write cache data to a .tmp file first, then rename() it to the final
path so readers never see a partially-written file.

https://claude.ai/code/session_01PauFrEKY4x3W5pDEqMtD6M
unlink() is POSIX-only; remove() is standard C and works on Windows
too (including MSVC without deprecation warnings).

https://claude.ai/code/session_01PauFrEKY4x3W5pDEqMtD6M
…ated-result

clang-tidy flags memcpy(dst, src, strlen(src)) as potentially
non-null-terminated. snprintf produces a properly terminated string
and keeps the intent clear.

https://claude.ai/code/session_01PauFrEKY4x3W5pDEqMtD6M
@ferronn-dev ferronn-dev force-pushed the claude/atomic-cache-writes-DSx9L branch from 2faeb25 to e76b235 Compare May 18, 2026 02:52
@ferronn-dev ferronn-dev merged commit 645ea21 into main May 18, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants