Files
Stefan HallerandClaude Opus 5.5 33e128eece Write state.yml atomically
os.WriteFile empties state.yml and then writes the new contents. If
lazygit crashes or the disk is full in between, the file is left empty
or partly written. An older lazygit version that runs at the same time
doesn't take the lock, so it can also read the file in this state.

Write the new contents to a temp file in the same folder and rename it
over state.yml. Sync the temp file before the rename. Otherwise the
rename can reach the disk before the data. If the machine then crashes
or loses power, state.yml is left filled with zero bytes; several users
on Windows had this (#3023).

Renaming replaces a symlink, gives the file new permissions, and
ignores a read-only state.yml. Keep the behavior of the in-place write
for these cases: replace the file that a symlink points to, give the
new file the permissions of the old one, and leave a read-only file
alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 08:10:59 +01:00
..
2026-11-15 08:10:59 +01:00
2025-11-15 10:46:23 +01:00