fix: use Path.replace() for Windows compatibility#74
Merged
Conversation
Path.rename() fails on Windows when destination exists (FileExistsError). Path.replace() works cross-platform and overwrites existing files. Added test to verify overwriting existing profiles file works.
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
oalami
approved these changes
Mar 3, 2026
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.
Summary
Fixes
FileExistsErroron Windows when runningworkato init.Problem
On Windows,
Path.rename()fails with[WinError 183] Cannot create a file when that file already existswhen the destination file exists. This happens duringworkato initbecausesave_profiles()is called multiple times (once to save profile data, once to set it as current).Solution
Changed
temp_file.rename(self.profiles_file)totemp_file.replace(self.profiles_file).Path.replace()works identically torename()but will overwrite the destination file if it exists, which is the expected behavior for atomic write patterns.Testing
test_save_profiles_overwrites_existingto verify consecutive saves work correctly