Add error handling for the filesystem operations of cache and index files

Signed-off-by: Muvaffak Onus <me@muvaf.com>
pull/11388/head
Muvaffak Onus 3 years ago
parent a48b87f32a
commit 42e61546f4

@ -152,12 +152,18 @@ func (r *ChartRepository) DownloadIndexFile() (string, error) {
fmt.Fprintln(&charts, name) fmt.Fprintln(&charts, name)
} }
chartsFile := filepath.Join(r.CachePath, helmpath.CacheChartsFile(r.Config.Name)) chartsFile := filepath.Join(r.CachePath, helmpath.CacheChartsFile(r.Config.Name))
os.MkdirAll(filepath.Dir(chartsFile), 0755) if err := os.MkdirAll(filepath.Dir(chartsFile), 0755); err != nil {
ioutil.WriteFile(chartsFile, []byte(charts.String()), 0644) return "", err
}
if err := ioutil.WriteFile(chartsFile, []byte(charts.String()), 0644); err != nil {
return "", err
}
// Create the index file in the cache directory // Create the index file in the cache directory
fname := filepath.Join(r.CachePath, helmpath.CacheIndexFile(r.Config.Name)) fname := filepath.Join(r.CachePath, helmpath.CacheIndexFile(r.Config.Name))
os.MkdirAll(filepath.Dir(fname), 0755) if err := os.MkdirAll(filepath.Dir(fname), 0755); err != nil {
return "", err
}
return fname, ioutil.WriteFile(fname, index, 0644) return fname, ioutil.WriteFile(fname, index, 0644)
} }

Loading…
Cancel
Save