Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion v2/pkgs/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (t *Tools) Install(ctx context.Context, payload *tools.ToolPayload) (*tools
key := correctTool.Name + "-" + correctTool.Version
// Check if it already exists
if t.behaviour == "keep" && pathExists(t.folder) {
location, ok := t.installed[key]
location, ok := t.getInstalledValue(key)
if ok && pathExists(location) {
// overwrite the default tool with this one
err := t.writeInstalled(path)
Expand Down Expand Up @@ -336,6 +336,13 @@ func (t *Tools) SetBehaviour(behaviour string) {
t.behaviour = behaviour
}

func (t *Tools) getInstalledValue(key string) (string, bool) {
t.mutex.RLock()
defer t.mutex.RUnlock()
location, ok := t.installed[key]
return location, ok
}

func pathExists(path string) bool {
_, err := os.Stat(path)
if err == nil {
Expand Down