Skip to content

Use atomic writes for versions.lock in resolve script#31

Merged
lex57ukr merged 1 commit intomainfrom
23-atomic-lockfile-writes
Feb 15, 2026
Merged

Use atomic writes for versions.lock in resolve script#31
lex57ukr merged 1 commit intomainfrom
23-atomic-lockfile-writes

Conversation

@lex57ukr
Copy link
Contributor

Summary

Prevents a truncated or partially written versions.lock if the resolve script exits mid-run. The lockfile is now written to a temp file first and atomically moved into place on success, with a cleanup trap that removes the temp file on early exit.

Related Issues

Fixes #23

Changes

  • Write lockfile content to a temp file instead of directly to versions.lock
  • Atomically mv the temp file into place after a successful write
  • Register an EXIT trap to clean up the temp file on script failure

Write the lockfile to a temp file first, then atomically move it
into place on success. A cleanup trap removes the temp file if the
script exits early due to a resolver failure, preventing a truncated
or partially written lockfile from replacing the existing one.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lex57ukr lex57ukr added the bug Something isn't working label Feb 15, 2026
@lex57ukr lex57ukr merged commit 452671f into main Feb 15, 2026
1 check passed
@lex57ukr lex57ukr deleted the 23-atomic-lockfile-writes branch February 15, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use atomic writes for versions.lock in resolve script

1 participant