Add comment to explain why the repositories file is read a second time

Signed-off-by: Patrick Decat <pdecat@gmail.com>
pull/5678/head
Patrick Decat 6 years ago
parent 3f3b5b42f8
commit 6b800509d0
No known key found for this signature in database
GPG Key ID: FD55B9BD5687D8FF

@ -135,7 +135,7 @@ func addRepository(name, url, username, password string, home helmpath.Home, cer
return fmt.Errorf("Looks like %q is not a valid chart repository or cannot be reached: %s", url, err.Error())
}
// Lock the repository file for concurrent processes synchronization and re-read its content before updating it
// Lock the repository file for concurrent goroutines or processes synchronization
fileLock := flock.New(home.RepositoryFile())
lockCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
@ -147,6 +147,8 @@ func addRepository(name, url, username, password string, home helmpath.Home, cer
return err
}
// Re-read the repositories file before updating it as its content may have been changed
// by a concurrent execution after the first read and before being locked
f, err = repo.LoadRepositoriesFile(home.RepositoryFile())
if err != nil {
return err

Loading…
Cancel
Save