mirror of https://github.com/helm/helm.git
refactor: use `os.ReadDir` for lightweight directory reading
`os.ReadDir` was added in Go 1.16 as part of the deprecation of `ioutil` package. It is a more efficient implementation than `ioutil.ReadDir` as stated here https://pkg.go.dev/io/ioutil#ReadDir. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
parent
c137bfb68b
commit
e12f3570b5
|
@ -400,12 +400,12 @@ func parseOCIRef(chartRef string) (string, string, error) {
|
|||
func (m *Manager) safeMoveDeps(deps []*chart.Dependency, source, dest string) error {
|
||||
existsInSourceDirectory := map[string]bool{}
|
||||
isLocalDependency := map[string]bool{}
|
||||
sourceFiles, err := ioutil.ReadDir(source)
|
||||
sourceFiles, err := os.ReadDir(source)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// attempt to read destFiles; fail fast if we can't
|
||||
destFiles, err := ioutil.ReadDir(dest)
|
||||
destFiles, err := os.ReadDir(dest)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -436,7 +436,7 @@ func (m *Manager) safeMoveDeps(deps []*chart.Dependency, source, dest string) er
|
|||
}
|
||||
|
||||
fmt.Fprintln(m.Out, "Deleting outdated charts")
|
||||
// find all files that exist in dest that do not exist in source; delete them (outdated dependendencies)
|
||||
// find all files that exist in dest that do not exist in source; delete them (outdated dependencies)
|
||||
for _, file := range destFiles {
|
||||
if !file.IsDir() && !existsInSourceDirectory[file.Name()] {
|
||||
fname := filepath.Join(dest, file.Name())
|
||||
|
|
Loading…
Reference in New Issue