mirror of
https://github.com/helm/helm.git
synced 2026-04-26 00:27:36 -04:00
Correctly determine repository-config lockfile path
helm repo add automatically creates a lockfile based on the repository config file path When the given filepath did not include a file extension, a lockfile in a nonexistent directory would have been created. Signed-off-by: Leon Bentrup <4458913+xanecs@users.noreply.github.com>
This commit is contained in:
parent
fc9b46067f
commit
f091b9cc01
1 changed files with 8 additions and 1 deletions
|
|
@ -95,7 +95,14 @@ func (o *repoAddOptions) run(out io.Writer) error {
|
|||
}
|
||||
|
||||
// Acquire a file lock for process synchronization
|
||||
fileLock := flock.New(strings.Replace(o.repoFile, filepath.Ext(o.repoFile), ".lock", 1))
|
||||
repoFileExt := filepath.Ext(o.repoFile)
|
||||
var lockPath string
|
||||
if len(repoFileExt) > 0 && len(repoFileExt) < len(o.repoFile) {
|
||||
lockPath = strings.Replace(o.repoFile, repoFileExt, ".lock", 1)
|
||||
} else {
|
||||
lockPath = o.repoFile + ".lock"
|
||||
}
|
||||
fileLock := flock.New(lockPath)
|
||||
lockCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
locked, err := fileLock.TryLockContext(lockCtx, time.Second)
|
||||
|
|
|
|||
Loading…
Reference in a new issue