From dc68a0bd5103f9b971730cbe2df11038bdf131de Mon Sep 17 00:00:00 2001 From: nxtcoder17 Date: Wed, 26 Jul 2023 20:19:29 +0530 Subject: [PATCH] fix(client.go): fixes premature index file download now when calling `AddOrUpdateChartRepo` the index file is downloaded only when the repo is not already cached in storage. --- client.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/client.go b/client.go index eac871e..2c65d15 100644 --- a/client.go +++ b/client.go @@ -175,6 +175,11 @@ func (c *HelmClient) AddOrUpdateChartRepo(entry repo.Entry) error { chartRepo.CachePath = c.Settings.RepositoryCache + if c.storage.Has(entry.Name) { + c.DebugLog("WARNING: repository name %q already exists", entry.Name) + return nil + } + if !registry.IsOCI(entry.URL) { _, err = chartRepo.DownloadIndexFile() if err != nil { @@ -182,11 +187,6 @@ func (c *HelmClient) AddOrUpdateChartRepo(entry repo.Entry) error { } } - if c.storage.Has(entry.Name) { - c.DebugLog("WARNING: repository name %q already exists", entry.Name) - return nil - } - c.storage.Update(&entry) err = c.storage.WriteFile(c.Settings.RepositoryConfig, 0o644) if err != nil {