-
Notifications
You must be signed in to change notification settings - Fork 653
Use os.Open for Windows realpath to handle long paths #862
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
Conversation
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.
Pull Request Overview
This PR updates the Windows realpath implementation to use os.Open instead of a custom openMetadata function that relies on undocumented SEH bits.
- Replaces CreateFile-based openMetadata with os.Open.
- Updates resource clean-up using f.Close() and converts the file descriptor with windows.Handle.
Comments suppressed due to low confidence (1)
internal/vfs/osvfs/realpath_windows.go:14
- [nitpick] Consider renaming the variable 'f' to a more descriptive name such as 'file' to improve code clarity.
f, err := os.Open(path)
The slow down comes from the fact that The problem is that the "just reading the attributes" access right does not map well with any Unix concept, so using just this access is not well supported by the |
70d420a
to
c1f52a4
Compare
Hm, unfortunately opening with flag=3 causes tests to fail due to |
Maybe I'll just use my helper for |
That will only work for absolute paths. You can have a relative path that is just one character long and still hit the long path limit if the working directory is 247 characters or more. Do you normally pass relative paths to |
They won't be relative; this FS abstraction is always absolute. |
My hand-written
open
function doesn't handle long paths, relying on the SEH bit Go normally sets. But, that bit is undocumented and seemingly isn't approved for using in releases, and isn't set in artifacts built by the Go fork used by Microsoft.Rather than use
CreateFile
directly, useos.Open
instead, which will handle long paths. I didn't do this initially because I thought it didn't work on directories, but it actually has worked since https://go.dev/cl/405275 a long time ago.I don't have a test for this because I can't seem to make a link with long enough paths in the tests...☹️
cc @qmuntal