pull/32366/merge
KartiK B Kenchi 2 months ago committed by GitHub
commit a2ab3b313d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -206,9 +206,14 @@ func TestDependencyUpdateCmd_DoNotDeleteOldChartsOnError(t *testing.T) {
} }
// Make sure tmpcharts-x is deleted // Make sure tmpcharts-x is deleted
tmpPath := filepath.Join(dir(chartname), fmt.Sprintf("tmpcharts-%d", os.Getpid())) entries, err := os.ReadDir(dir(chartname))
if _, err := os.Stat(tmpPath); !errors.Is(err, fs.ErrNotExist) { if err != nil {
t.Fatal("tmpcharts dir still exists") t.Fatal(err)
}
for _, entry := range entries {
if entry.IsDir() && strings.HasPrefix(entry.Name(), "tmpcharts-") {
t.Fatalf("tmpcharts directory still exists: %s", entry.Name())
}
} }
} }

@ -251,7 +251,6 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error {
} }
destPath := filepath.Join(m.ChartPath, "charts") destPath := filepath.Join(m.ChartPath, "charts")
tmpPath := filepath.Join(m.ChartPath, fmt.Sprintf("tmpcharts-%d", os.Getpid()))
// Check if 'charts' directory is not actually a directory. If it does not exist, create it. // Check if 'charts' directory is not actually a directory. If it does not exist, create it.
if fi, err := os.Stat(destPath); err == nil { if fi, err := os.Stat(destPath); err == nil {
@ -267,9 +266,14 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error {
} }
// Prepare tmpPath // Prepare tmpPath
if err := os.MkdirAll(tmpPath, 0o755); err != nil { tmpPath, err := os.MkdirTemp(m.ChartPath, "tmpcharts-*")
if err != nil {
return err return err
} }
// Maintain compatibility with existing permissions
if err := os.Chmod(tmpPath, 0o755); err != nil && m.Debug {
fmt.Fprintf(m.Out, "warning: failed to set permissions on temporary directory %s: %v\n", tmpPath, err)
}
defer os.RemoveAll(tmpPath) defer os.RemoveAll(tmpPath)
fmt.Fprintf(m.Out, "Saving %d charts\n", len(deps)) fmt.Fprintf(m.Out, "Saving %d charts\n", len(deps))

Loading…
Cancel
Save