Repository navigation
fix(session): fix snapshot write failure on Windows - #548
Merged
Merged
Conversation
os.rename cannot overwrite an existing file on Windows, causing all subsequent saves to fail after the first write. Remove the target file before renaming the temporary file, keeping the operation atomic on platforms that support it. Fixes sudo-tee#545 Fixes sudo-tee#541 Bug 3 Fixes sudo-tee#546
wzj-zz
force-pushed
the
fix/session-tab-persistence
branch
from
October 21, 2026 23:18
2478990 to
665d1b9
Compare
Collaborator
|
thanks! |
Owner
|
Thanks for taking care of this. I was a bit swamped the past days. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows,
os.rename()cannot overwrite an existing file. After the first snapshot write succeeds, all subsequent writes fail with "File exists" because the target file already exists.This causes three reported bugs:
<C-a>session switch is not persistedAll three share the same root cause: the snapshot file is never updated after the initial write, so any changes (new tabs, session switches, session deletions) are silently lost.
Fix
On Windows, remove the existing snapshot file before renaming the temporary file. On Linux,
os.rename()already supports overwriting atomically, so no change is needed.Changes
lua/opencode/services/session_tab_persistence.lua: Addos.remove(path)beforeos.rename()on Windows inwrite()Fixes #545
Fixes #541 (Bug 3)
Fixes #546