diff --git a/v2/pkgs/tools.go b/v2/pkgs/tools.go index c84d207f..379b7a52 100644 --- a/v2/pkgs/tools.go +++ b/v2/pkgs/tools.go @@ -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) @@ -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 {