-
Notifications
You must be signed in to change notification settings - Fork 734
Detect Windows junctions with GetFileAttributesEx #2013
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
base: main
Are you sure you want to change the base?
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 refactors Windows junction and symlink detection by replacing the Realpath-based approach with a dedicated IsSymlinkOrJunction function. The change improves efficiency by using direct Windows API calls to check for reparse points instead of resolving full paths.
- Adds platform-specific
isSymlinkOrJunctionimplementations for Windows and Unix-like systems - Updates
internal.Commonstruct to useIsSymlinkOrJunctioninstead ofRealpathfield - Simplifies junction detection logic in
GetAccessibleEntries
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/vfs/osvfs/symlink_windows.go | New file implementing Windows-specific junction/symlink detection using FILE_ATTRIBUTE_REPARSE_POINT |
| internal/vfs/osvfs/symlink_other.go | New file with nil function stub for Unix-like systems where detection is unnecessary |
| internal/vfs/osvfs/os.go | Updates osVFS initialization to use IsSymlinkOrJunction instead of Realpath |
| internal/vfs/internal/internal.go | Replaces Realpath field with IsSymlinkOrJunction in Common struct and simplifies detection logic in GetAccessibleEntries |
|
Any specific differences you've seen in perf? |
|
Haven't tested yet, just cleaning up some TODOs with my name on it. On any project I have it probably won't be very noticable... |
|
To actually test this, I switched us over to the Microsoft fork of Go, which disables the SEH bit that auto-handles longpaths. I can split that out into its own PR for clarity if desired. |
Faster than doing a realpath + comparison.