internal/fs: don't clone symlinks on windows#781
Conversation
1ab4923 to
34d3314
Compare
| if err = os.Symlink(srcPath, symlinkPath); err != nil { | ||
| t.Fatalf("could not create symlink: %v", err) | ||
| } | ||
| if runtime.GOOS == "window" { |
|
Transforming symlinks into their referent directory and copying them is a pretty drastic change. For some of the uses of this func, it's likely fine. Others might present complications, though. Could we please enumerate each of the places this logic will be triggered (so, calls from outside the |
|
Just to clarify, we don't transform the symlink into anything.
This renders the symlink useless on Windows. So if a dependency relies on symlinks functioning, something will most likely break and that is the part that really worries me. |
|
For the record,
|
| // Creating symlinks on Windows require an additional permission regular | ||
| // users aren't granted usually. So we skip cloning the symlink nd copy the | ||
| // file content as a fall back instead. | ||
| if sym && runtime.GOOS != "windows" { |
There was a problem hiding this comment.
what if we were to try it even on windows, and if we encounter the particular error, then fall back to cloning?
There was a problem hiding this comment.
Should work.
I'm only worried about not having a clear path of execution. The more conditionals paths we have the harder it's to reproduce output or debug strange behavior because the input list grows exponentially.
There was a problem hiding this comment.
of course - more if branches, more cyclomatic complexity. but the side effects here worry me enough that i think it's merited 😄
db67dbf to
80ad660
Compare
sdboyer
left a comment
There was a problem hiding this comment.
hmm, the review looked good, but apparently we have test failures 😢
d4803f7 to
2ea710d
Compare
|
Fixed tests. |
This change updates TestCopyFileSymlink tests and renames copySymlink to cloneSymlink to clarify the intention. Fixes golang#773 Signed-off-by: Ibrahim AshShohail <[email protected]>
545881f to
90c2a36
Compare
| } else if sym { | ||
| return cloneSymlink(src, dst) | ||
| if err := cloneSymlink(src, dst); err != nil { | ||
| if runtime.GOOS == "windows" && strings.HasSuffix(err.Error(), "A required privilege is not held by the client.") { |
There was a problem hiding this comment.
this isn't i18n-friendly. not a blocker, necessarily, but is there any way we could sniff the system actual error type here? obviously that means syscall, so this'd have to be a in a windows-tagged file.
There was a problem hiding this comment.
Good catch. Didn't think of that. Updating now.
There was a problem hiding this comment.
I think I solved it in an OS-independent way. Let me know if a windows-tagged file is still needed.
Signed-off-by: Ibrahim AshShohail <[email protected]>
fb26cc3 to
ced76d2
Compare
sdboyer
left a comment
There was a problem hiding this comment.
yeah, i think we're good here. thanks for your patience, as always! 🎉
What does this do / why do we need it?
fs.copyFilecallsfs.copySymlinkon Windows which fails if the user doesn't have the required permission. This is a very common case since symlinks are used heavily on Windows.This change renames
fs.copySymlinktofs.cloneSymlinkto clarify the intent and skips calling it when on Windows to fall back to copying the file content instead.What should your reviewer look out for in this PR?
Generic review.
Which issue(s) does this PR fix?
Fixes #773