Skip to content

Commit be311bd

Browse files
authored
fix: don't error when existing symlink points at correct path (#1081)
## Summary Update error handling in wrapnix package to succeed if intended symlinks already exist ## How was it tested? Manually testing.
1 parent 6d7eb36 commit be311bd

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

internal/wrapnix/wrapper.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,18 @@ func createSymlinksForSupportDirs(projectDir string) error {
145145
newname := filepath.Join(projectDir, plugin.WrapperPath, dir.Name())
146146

147147
if err := os.Symlink(oldname, newname); err != nil {
148+
// ignore if the symlink already exists
149+
if errors.Is(err, os.ErrExist) {
150+
existing, readerr := os.Readlink(newname)
151+
if readerr != nil {
152+
return errors.WithStack(readerr)
153+
}
154+
if existing == oldname {
155+
continue
156+
}
157+
return errors.Errorf("symlink %s already exists and points to %s", newname, existing)
158+
159+
}
148160
return err
149161
}
150162
}

0 commit comments

Comments
 (0)