From 4d6a2461f394f171d871e4680b4dfd439c97961e Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Thu, 17 Oct 2019 14:27:38 -0700 Subject: [PATCH] fix(cmd): acquire repository.lock Signed-off-by: Matthew Fisher --- cmd/helm/repo_add.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/helm/repo_add.go b/cmd/helm/repo_add.go index a28bb82a1..1c84ad8d6 100644 --- a/cmd/helm/repo_add.go +++ b/cmd/helm/repo_add.go @@ -23,6 +23,7 @@ import ( "io/ioutil" "os" "path/filepath" + "strings" "time" "github.com/gofrs/flock" @@ -85,8 +86,8 @@ func (o *repoAddOptions) run(out io.Writer) error { return err } - // Lock the repository file for concurrent goroutines or processes synchronization - fileLock := flock.New(o.repoFile) + // Acquire a file lock for process synchronization + fileLock := flock.New(strings.Replace(o.repoFile, filepath.Ext(o.repoFile), ".lock", 1)) lockCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() locked, err := fileLock.TryLockContext(lockCtx, time.Second)