-
Notifications
You must be signed in to change notification settings - Fork 48
Implement proper renameFile on Windows #146
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
Implement proper renameFile on Windows #146
Conversation
Symlinks on Windows are implemented using NTFS reparse points. Reparse points are also used when creating volume mounts on Windows. As far as golang is concerned, mountpoints and symlinks look the same. This change makes the distinction between the two and allows safely renaming symlinks, while erring out for anything else that looks like a symlink. Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
283078c
to
4e7d36d
Compare
diskwriter_windows.go
Outdated
// +build windows | ||
|
||
package fsutil | ||
|
||
import ( | ||
"fmt" | ||
ioFS "io/fs" |
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's up with this package alias. fs
doesn't even seem to be used elsewhere in the file.
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.
remnant from splitting up the previous PR. Changing it now.
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.
ahh! I remember now. There is a type fs struct{}
defined here: https://github.com/tonistiigi/fsutil/blob/master/fs.go#L29
gabriel@arrakis:~/work/msft/fsutil$ GOOS=windows go build ./...
# github.com/tonistiigi/fsutil
./fs.go:29:6: fs already declared through import of package fs ("io/fs")
./diskwriter_windows.go:8:2: other declaration of fs
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.
The only way we can import io/fs
is if we rename that struct. I think the aliased import is probably the path with the least amount of code changes 😄 . What do you think?
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.
Ok, but make it all lowercase.
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.
Import was renamed. Please take another look.
6861ae6
to
4e7d36d
Compare
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
5b9d415
to
2305f0a
Compare
Symlinks on Windows are implemented using NTFS reparse points. Reparse points are also used when creating volume mounts on Windows. As far as golang is concerned, mountpoints and symlinks look the same. This change makes the distinction between the two and allows safely renaming symlinks, while erring out for anything else that looks like a symlink.
Signed-off-by: Gabriel Adrian Samfira gsamfira@cloudbasesolutions.com