Repository navigation
Flatten a backup's source path on Windows too - #125
Merged
Merged
Conversation
The source path is squashed into one file name so a backup says whose it is. It only replaced `/`. On Windows the separator is `\`, so the name kept its backslashes -- and `Path::join` given an absolute path discards the base entirely. The "file inside the backup directory" quietly became the user's own configuration file. What happened next was `create_new`, reporting that the file already exists. That complaint is the thing that saved us: without it the backup step would have written backup text over the user's configuration, and not damaging other people's files is the entire reason this module exists. The colon goes too. The one in `C:` is not legal in a Windows file name. The test runs on macOS and fails against the old implementation, which is the part worth keeping: a `\` separator survives string replacement of `/` on any platform, so this never needed a Windows machine to be caught. It was caught by one only because nothing had asked. Found by the Windows CI job in #119. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
fylorn
force-pushed
the
fix/windows-backup-path
branch
from
September 23, 2026 06:40
b77d1ca to
8ca5ae2
Compare
Closed
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.
The second real bug the Windows CI job found, and worse than the first.
The source path is squashed into one file name so a backup says whose it is —
/Users/x/.claude/settings.jsonbecomesUsers%x%.claude%settings.json. It only replaced/.On Windows the separator is
\, so the name kept its backslashes — andPath::joingiven an absolute path discards the base entirely. The "file inside the backup directory" quietly became the user's own configuration file.What happened next was
create_new, reporting that the file already exists. That complaint is the thing that saved us. Without it the backup step would have written backup text over the user's configuration — and not damaging other people's files is the entire reason this module exists.The comment above that call reads "the directory was just created, so there should be no file by this name; if there is, better to fail than overwrite." That should is a certainty on the other platform.
The colon goes too: the one in
C:is not legal in a Windows file name.The part worth keeping
The test runs on macOS and fails against the old implementation. I put the old code back to confirm it —
FAILED.A
\separator survives a string replacement of/on any platform. This never needed a Windows machine to be caught. It was caught by one only because nothing had ever asked the question.Verified
clippy clean workspace-wide, full test suite green (98 in tw-adopt), and the new test verified to fail against the previous implementation rather than merely passing against the new one.
Found by the Windows CI job in #119, which is stacked on this.
🤖 Generated with Claude Code