Skip to content

Conversation

@ThomasWaldmann
Copy link
Member

@ThomasWaldmann ThomasWaldmann commented Jan 22, 2026

Fixes #7120. Fixes #4731. Fixes #8474.

Also incorporated the changes from #9171, thanks to @valtron!

@ThomasWaldmann
Copy link
Member Author

ThomasWaldmann commented Jan 22, 2026

also discussed os.path.normpath/abspath/realpath usage on windows, #7120.

@ThomasWaldmann
Copy link
Member Author

@jedenastka do you have feedback about the contents of the plan?

@jedenastka
Copy link

jedenastka commented Jan 25, 2026

My concern is that it is AI generated. To me, this signals laziness and lack of thought, which is not something I want to see in a backup tool.

A plan means you're actually planning something. If AI does it, it is not planning, because AI cannot think.

Feel free to disagree. I do not plan to engage in further conversation.

@ThomasWaldmann
Copy link
Member Author

@jedenastka Well, I understand your concerns. I also have quite some concerns about AI usage, but (as so often), it depends on how you use it.

The planning one can see here is the result of an hours long "discussion" between me and the AI, so maybe that was not what you meant with "lazy" and "lack of thought". It helped not to overlook aspects or places of the needed changes.

Just wanted to clarify that. You don't need to reply if you do not have more specific feedback about the plan contents.

@ThomasWaldmann ThomasWaldmann marked this pull request as draft January 25, 2026 03:55
@RonnyPfannschmidt
Copy link
Contributor

wrt drive letters and extraction - how about storing the "extraction root" in the archive in a way that all items in a archive are relative paths to the extraction root

this would come with some perks like backing up the same file tree in a different location would generate the same archive content including path names for all but the archive metadata

wrt forbidden path names on windows - would using unc full paths work - i dislike schemes that may trigger a overlap - and statefull overlap prevention is unreasonably expensive in terms of implementation complexity

@ThomasWaldmann
Copy link
Member Author

@RonnyPfannschmidt one root would only be the simplest use case, but would not be enough for the general case. You can give multiple paths to borg as cli params or via the patterns file. You can even feed a list of arbitrary paths to borg.

@ThomasWaldmann ThomasWaldmann changed the title AI agent plan for path sep and windows related changes path sep and windows related changes Jan 25, 2026
@codecov
Copy link

codecov bot commented Jan 25, 2026

Codecov Report

❌ Patch coverage is 92.98246% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.86%. Comparing base (85b2ca2) to head (8792a1c).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/borg/helpers/fs.py 77.77% 1 Missing and 1 partial ⚠️
src/borg/helpers/parseformat.py 75.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9264      +/-   ##
==========================================
+ Coverage   75.84%   75.86%   +0.01%     
==========================================
  Files          86       86              
  Lines       14745    14753       +8     
  Branches     2194     2194              
==========================================
+ Hits        11184    11193       +9     
+ Misses       2888     2887       -1     
  Partials      673      673              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ThomasWaldmann ThomasWaldmann marked this pull request as ready for review January 28, 2026 02:57
@ThomasWaldmann ThomasWaldmann mentioned this pull request Jan 28, 2026
This commit implements a comprehensive approach to Windows path compatibility
by standardizing on forward slashes (/) for all internal path representations
while maintaining cross-platform archive compatibility.

Core Strategy:
- All internal paths now use forward slashes as separators on all platforms
- Boundary normalization: backslashes converted to forward slashes at entry
  points on Windows (filesystem paths only, not user patterns)
- Literal backslashes from POSIX archives replaced with % on Windows extraction

Key Changes:

Path Handling (helpers/fs.py):
- Added slashify(): converts backslashes to forward slashes on Windows
- Added percentify(): replaces backslashes with % for POSIX-to-Windows extraction
- Updated make_path_safe() to check for Windows-style .. patterns
- Changed get_strip_prefix() to use posixpath.normpath instead of os.path.normpath
- Updated remove_dotdot_prefixes() to use forward slashes consistently

Pattern Matching (patterns.py):
- Replaced os.path with posixpath throughout for consistent separator handling
- Updated PathFullPattern, PathPrefixPattern, FnmatchPattern, ShellPattern
- All pattern matching now uses / as separator regardless of platform
- Removed platform-specific os.sep usage

Archive Operations (archive.py, item.pyx):
- Applied slashify() to paths during archive creation on Windows
- Added percentify/slashify encoding/decoding for symlink targets
- Ensures archived paths always use forward slashes

Command Line (archiver/create_cmd.py, extract_cmd.py):
- Replaced os.path.join/normpath with posixpath equivalents
- Added slashify() for stdin-provided paths on Windows
- Updated strip_components to use / separator
- Changed PathSpec to FilesystemPathSpec for proper path handling

Repository (repository.py, legacyrepository.py):
- Replaced custom _local_abspath_to_file_url() with Path.as_uri()

Documentation (archiver/help_cmd.py):
- Clarified that all archived paths use forward slashes
- Added note about Windows absolute paths in archives (e.g., C/Windows/System32)
- Documented backslash-to-percent replacement for POSIX archives on Windows

Impact:
- Windows users can now create and extract archives with consistent path handling
- Cross-platform archives remain compatible
- Pattern matching works identically on all platforms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix windows "file:" URLs, re-enable windows CI os.path.normpath converts to backslashes on windows windows: normalize backslashes to slashes

3 participants