-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
add: [Windows] Drive root parse fix #3328
Conversation
Can some other windows user verify and test this? @slothbag ? |
10b5f22
to
f2b271c
Compare
Changed comment, "drive letter" -> "drive path". |
@mateon1 could you give it a test. |
Sorry for the late response. I gave this PR a test. It doesn't seem to fix the problem, the |
Thanks @mateon1 I also rebuilt with Go 1.7.3 and still get the same. I'm not sure where the discrepancy could be, any idea? I'm also not sure how I'd need some guidance on what the behavior should be for both Sorry for the verbosity but I have to be pedantic with these DOS path semantics and behaviors. |
d431c12
to
b59dcb5
Compare
Alright, so I wrote something here that should properly handle all cases and hopefully not break anything. If anyone has suggestions for improvement, I'd like to hear them. I'm also not sure if the comments are overkill, but these are weird Windows specific special cases. Everything works as normal in my case but I'd like others to test this if they can. If everything looks good I'll squash these and rebase on master. Pinging @slothbag, @mateon1, and any other Windows users that see this. |
Unfortunately I don't have the time to test this right now, but looking at the screenshot that pretty much covers the scenarios I would run.. It looks pretty good to me. |
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.
Lets make sure to consider the effects these changes will have on linux and OSX systems. (among others)
commands/cli/parse.go
Outdated
switch len(fpath) { | ||
case 3: | ||
// X: will be cleaned to `X:.` which is not what is intended, a case for handling dot relative paths is above | ||
if fpath[0] != '/' && fpath[1:3] == ":." { |
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.
Hrm, we need to special case this to only run on windows. In linux, X:.
is a perfectly valid filename
@whyrusleeping |
b59dcb5
to
7f92b0d
Compare
ee06194
to
0aa5a88
Compare
Modified the comments to have consistent quotations and changed some wording, also shortened the error message. Unless anyone has any issues with the logic or the wording, this should be good to go. |
0aa5a88
to
79b285a
Compare
@whyrusleeping o/ |
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.
One request, then you'll need to rebase this to fix the merge conflicts.
After that this LGTM
commands/cli/parse.go
Outdated
// special cases for Windows drive roots i.e. `X:\` and their long form `\\?\X:\` | ||
// drive path must be preserved as `X:\` (or it's longform) and not converted to `X:`, `X:.`, `\`, or `/` here | ||
if osh.IsWindows() { | ||
switch len(fpath) { |
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.
can we extract this out into a windowsParseFile
sort of thing?
5a1d3b7
to
eed8528
Compare
Like this? |
License: MIT Signed-off-by: Dominic Della Valle <[email protected]>
License: MIT Signed-off-by: Dominic Della Valle <[email protected]>
Going to assume the travis failure is an issue with caching old code. |
Previously when adding the root of a drive on Windows (either directly through
X:\
or via.
while inX:
), ipfs would prefix everything and not handle directories properly in a manner simillar to this issue:#1922This does not happen with paths or files underneath the root, it's just when adding the root itself. 👻
This can be fixed by preserving the full path
X:\
instead of usingX:
as a base when specifying the root of a drive only. As an aside it would not be valid to use/
instead, since/
is relative to the drive in your working directory on Windows, not an absolute path. Using/
while addingY:\
fromX:\
would either give you N contents fromX
: or panic ifX:
contains less items in the root thanY:
does. Preserving the full path doesn't have this issue.I make sure not to act on paths starting with
/
and check for a backslash, to my knowledge a valid input path like that should only show up on Windows.Using long path prefix form
\\?\x:
will still give the incorrect behavior, I don't think it's necessary to check for this but it could be caught in the same way, then converted from the long form to the short formX:\
Any issues with this and should long form be handled too?