mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-11-21 04:46:29 +03:00
Two lazygit instances can update state.yml at the same moment. Both read the same contents, and the second write discards the change of the first. Also, os.WriteFile empties the file before it writes the new contents. An instance that reads the file at that moment gets an empty file, which reads as the default state, or a partial one, which doesn't parse. This can already happen when several instances start at once, for example when a tmux session is restored, because each of them updates state.yml at startup. Take an exclusive lock on a separate lock file while updating, and a shared one while reading. Each lock call opens the lock file anew, so the lock also keeps goroutines of the same instance apart; the test relies on this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>