Skip to content

Commit dfa826f

Browse files
committed
Apply suggestion
1 parent 39204c7 commit dfa826f

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

pkg/fsutils/fsutils_windows.go

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,27 @@ import (
1111

1212
func evalSymlinks(path string) (string, error) {
1313
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
3133
}
3234
}
33-
return "", err
3435
}
35-
return resolved, nil
36+
return "", err
3637
}

0 commit comments

Comments
 (0)