-
-
Notifications
You must be signed in to change notification settings - Fork 743
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
Properly normalise paths on Windows #7676
Conversation
Codecov Report
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. @@ Coverage Diff @@
## master #7676 +/- ##
==========================================
- Coverage 83.87% 83.76% -0.12%
==========================================
Files 66 66
Lines 11873 11897 +24
Branches 2149 2155 +6
==========================================
+ Hits 9958 9965 +7
- Misses 1346 1359 +13
- Partials 569 573 +4
|
src/borg/helpers/fs.py
Outdated
if is_win32: | ||
path = os.path.splitdrive(path)[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what i already wondered: is borg already getting paths with slashes (and not backslashes)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added some logging, it looks like it is:
$ pytest -s -k "test_archived_paths and not remote and not binary"
=========================================================================================== test session starts ============================================================================================
platform win32 -- Python 3.10.9, pytest-7.2.0, pluggy-1.0.0
benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
Tests enabled: root, hardlinks, modes
Tests disabled: BSD flags, fuse2, fuse3, symlinks, atime/mtime
rootdir: C:/msys64/home/Rayyan/borg, configfile: setup.cfg
plugins: benchmark-4.0.0, cov-4.0.0, forked-1.4.0, xdist-3.1.0
collected 1746 items / 1745 deselected / 1 selected
src/borg/testsuite/archiver/create_cmd.py
self.cmd output START
self.cmd output END
self.cmd output START
remove_dotdot_prefixes path = input
remove_dotdot_prefixes path = input/test
remove_dotdot_prefixes path = C:/Users/Rayyan/AppData/Local/Temp/tmpz08pkzkq/input/test
self.cmd output END
self.cmd output START
input
input/test
Users/Rayyan/AppData/Local/Temp/tmpz08pkzkq/input/test
self.cmd output END
self.cmd output START
{"flags": 0, "gid": 0, "group": "root", "healthy": true, "hlid": "", "mode": "drwxrwxrwx", "mtime": "2023-06-25T21:38:16.244628+01:00", "path": "input", "size": 0, "target": "", "type": "d", "uid": 0, "user": "root"}
{"flags": 0, "gid": 0, "group": "root", "healthy": true, "hlid": "", "mode": "-rw-rw-rw-", "mtime": "2023-06-25T21:38:16.244628+01:00", "path": "input/test", "size": 0, "target": "", "type": "-", "uid": 0, "user": "root"}
{"flags": 0, "gid": 0, "group": "root", "healthy": true, "hlid": "", "mode": "-rw-rw-rw-", "mtime": "2023-06-25T21:38:16.244628+01:00", "path": "Users/Rayyan/AppData/Local/Temp/tmpz08pkzkq/input/test", "size": 0, "target": "", "type": "-", "uid": 0, "user": "root"}
self.cmd output END
.
==================================================================================== 1 passed, 1745 deselected in 1.63s ====================================================================================
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know where exactly the usual backslashes on windows are transformed to slashes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just tested making an archive manually with borg.exe, looks like the paths are still backslashes...
strange. will look into this more.
could be that the test is passing it a forward slash path but at the terminal it's getting passed a backward slash path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
appears to work fine now but i don't know if posixpath.normpath is needed in other places as well
There was a discussion on the mailing list about not taking drive letters into account on Windows, which prevents using files of multiple drives in the same archive. That feels a bit strange, especially as some softwares like Cygwin simply use the drive letter character as part of some path and Borg might do the same. The following is an example:
vs.
|
@ams-tschoening makes sense. Just one thing might complicate this a bit: E.g.
would we back up this like?:
|
In my opinion yes and should be in-line with what Borg documents about paths in other OS as well: They are used as is. If one wants relative paths, one needs to tschoening@tschoening-nb MINGW64 ~/Documents
$ pwd
/c/Users/tschoening/Documents |
Note: lower case "c" on mingw64 (not uppercase). |
Should you care about that? Borg doesn't normalize upper-lower case in any other path or does it on Windows? In my opinion things should be forwarded 1:1. |
Do you have a link to this discussion? |
https://mail.python.org/pipermail/borgbackup/2023q2/002269.html An answer is missing, because I've sent privately by accident first. |
e327a24
to
ebbf8b0
Compare
Use forward slashes and integrate the drive letter into the path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
anything stopping this from being merged? |
No. :) |
Fixes #7666