@@ -11,26 +11,27 @@ import (
11
11
12
12
func evalSymlinks (path string ) (string , error ) {
13
13
resolved , err := filepath .EvalSymlinks (path )
14
- if err != nil {
15
- // This is a workaround for the behavior of filepath.EvalSymlinks, which fails with
16
- // syscall.ENOTDIR if the specified path contains a junction on Windows. Junctions
17
- // can occur, for example, when a volume is mounted as a subdirectory inside another
18
- // drive. This can usually happen when using the Dev Drives feature and replacing
19
- // existing directories. See: https://github.com/golang/go/issues/40180
20
- //
21
- // Since syscall.ENOTDIR is only returned when calling filepath.EvalSymlinks on
22
- // Windows if part of the presented path is a junction and nothing before was a
23
- // symlink, we simply treat this as NOT symlink, because a symlink over the junction
24
- // makes no sense at all.
25
- if errors .Is (err , syscall .ENOTDIR ) {
26
- if _ , sErr := os .Stat (path ); sErr == nil {
27
- // If exists, we make the path absolute, to be sure...
28
- if abs , aErr := filepath .Abs (path ); aErr == nil {
29
- return abs , nil
30
- }
14
+ if err == nil {
15
+ return resolved , nil
16
+ }
17
+
18
+ // This is a workaround for the behavior of filepath.EvalSymlinks, which fails with
19
+ // syscall.ENOTDIR if the specified path contains a junction on Windows. Junctions
20
+ // can occur, for example, when a volume is mounted as a subdirectory inside another
21
+ // drive. This can usually happen when using the Dev Drives feature and replacing
22
+ // existing directories. See: https://github.com/golang/go/issues/40180
23
+ //
24
+ // Since syscall.ENOTDIR is only returned when calling filepath.EvalSymlinks on
25
+ // Windows if part of the presented path is a junction and nothing before was a
26
+ // symlink, we simply treat this as NOT symlink, because a symlink over the junction
27
+ // makes no sense at all.
28
+ if errors .Is (err , syscall .ENOTDIR ) {
29
+ if _ , sErr := os .Stat (path ); sErr == nil {
30
+ // If exists, we make the path absolute, to be sure...
31
+ if abs , aErr := filepath .Abs (path ); aErr == nil {
32
+ return abs , nil
31
33
}
32
34
}
33
- return "" , err
34
35
}
35
- return resolved , nil
36
+ return "" , err
36
37
}
0 commit comments