-
-
Notifications
You must be signed in to change notification settings - Fork 821
swidth: use cross platform implementation, fixes #7493 #9283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ThomasWaldmann
wants to merge
6
commits into
borgbackup:master
Choose a base branch
from
ThomasWaldmann:swidth-master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
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
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #9283 +/- ##
==========================================
+ Coverage 75.84% 75.89% +0.04%
==========================================
Files 86 86
Lines 14745 14758 +13
Branches 2194 2197 +3
==========================================
+ Hits 11184 11200 +16
+ Misses 2888 2884 -4
- Partials 673 674 +1 ☔ View full report in Codecov by Sentry. |
7562aa9 to
48387e0
Compare
CI: the windows runner installs Python 3.14 now and thus we need a more recent pyinstaller to be compatible with that.
This implementation should be good enough for our usecase (paths) and has no external dependencies. There is also a wcwidth library which might be even better, but would add another dependency.
48387e0 to
dc65861
Compare
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.
This implementation should be good enough for our usecase (paths) and has no external dependencies.
There is also a wcwidth library which might be even better, but would add another dependency.