pull/30868/merge
foyerunix 2 weeks ago committed by GitHub
commit 6540ed2f6f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -152,23 +152,6 @@ func (p *Pull) Run(chartRef string) (string, error) {
if !filepath.IsAbs(ud) { if !filepath.IsAbs(ud) {
ud = filepath.Join(p.DestDir, ud) ud = filepath.Join(p.DestDir, ud)
} }
// Let udCheck to check conflict file/dir without replacing ud when untarDir is the current directory(.).
udCheck := ud
if udCheck == "." {
_, udCheck = filepath.Split(chartRef)
} else {
_, chartName := filepath.Split(chartRef)
udCheck = filepath.Join(udCheck, chartName)
}
if _, err := os.Stat(udCheck); err != nil {
if err := os.MkdirAll(udCheck, 0755); err != nil {
return out.String(), fmt.Errorf("failed to untar (mkdir): %w", err)
}
} else {
return out.String(), fmt.Errorf("failed to untar: a file or directory with the name %s already exists", udCheck)
}
return out.String(), chartutil.ExpandFile(ud, saved) return out.String(), chartutil.ExpandFile(ud, saved)
} }
return out.String(), nil return out.String(), nil

@ -61,6 +61,15 @@ func Expand(dir string, r io.Reader) error {
return err return err
} }
// Check if chartdir conflict with an already existing directory
if _, err := os.Stat(chartdir); err != nil {
if err := os.MkdirAll(chartdir, 0755); err != nil {
return fmt.Errorf("failed to untar (mkdir): %w", err)
}
} else {
return fmt.Errorf("failed to untar: a file or directory with the name %s already exists", chartdir)
}
// Copy all files verbatim. We don't parse these files because parsing can remove // Copy all files verbatim. We don't parse these files because parsing can remove
// comments. // comments.
for _, file := range files { for _, file := range files {

Loading…
Cancel
Save