Skip to content

Conversation

@ChrisPenner
Copy link
Member

@ChrisPenner ChrisPenner commented Nov 4, 2025

Overview

@dolio recently had an "idemptotent" transcript file get wiped out because of a ctrl-c at a non-opportune moment.
This makes output-writing atomic on unix systems, and it should be slightly less likely to cause trouble on windows as well.

Implementation notes

  • Add helper to the prelude for atomically replacing a file, which writes to a temp file then does a rename over the destination
  • Uses this new helper in the transcript output writer

Test coverage

Existing transcripts should serve as proof this is working.

I also tried making some transcript changes to ensure they took effect.

@ChrisPenner ChrisPenner changed the title Cp/atomic transcript files Atomic transcript output file rewrites Nov 4, 2025
@ChrisPenner ChrisPenner marked this pull request as ready for review November 4, 2025 23:21
@ChrisPenner ChrisPenner requested a review from aryairani November 4, 2025 23:21
@ChrisPenner
Copy link
Member Author

Ugh, yeah looks like Windows problems

@ChrisPenner ChrisPenner marked this pull request as draft November 5, 2025 22:25
@ChrisPenner ChrisPenner removed the request for review from aryairani November 5, 2025 22:25
@dolio
Copy link
Contributor

dolio commented Nov 6, 2025

What if instead of a temp file, you temporarily created the output.md, then renamed it over the original .md? Not as general purpose, but might work for this case.

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.

3 participants