Merge pull request #10574 from Juneezee/refactor/os.ReadDir

refactor: use `os.ReadDir` for lightweight directory reading
pull/10554/head
Martin Hickey 3 years ago committed by GitHub
commit 21952fccc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -400,12 +400,12 @@ func parseOCIRef(chartRef string) (string, string, error) {
func (m *Manager) safeMoveDeps(deps []*chart.Dependency, source, dest string) error { func (m *Manager) safeMoveDeps(deps []*chart.Dependency, source, dest string) error {
existsInSourceDirectory := map[string]bool{} existsInSourceDirectory := map[string]bool{}
isLocalDependency := map[string]bool{} isLocalDependency := map[string]bool{}
sourceFiles, err := ioutil.ReadDir(source) sourceFiles, err := os.ReadDir(source)
if err != nil { if err != nil {
return err return err
} }
// attempt to read destFiles; fail fast if we can't // attempt to read destFiles; fail fast if we can't
destFiles, err := ioutil.ReadDir(dest) destFiles, err := os.ReadDir(dest)
if err != nil { if err != nil {
return err return err
} }
@ -436,7 +436,7 @@ func (m *Manager) safeMoveDeps(deps []*chart.Dependency, source, dest string) er
} }
fmt.Fprintln(m.Out, "Deleting outdated charts") 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 { for _, file := range destFiles {
if !file.IsDir() && !existsInSourceDirectory[file.Name()] { if !file.IsDir() && !existsInSourceDirectory[file.Name()] {
fname := filepath.Join(dest, file.Name()) fname := filepath.Join(dest, file.Name())

Loading…
Cancel
Save