Merge pull request #19526 from HirazawaUi/fix-not-remove-tempfile

remove temporary files when copy
This commit is contained in:
OpenShift Merge Robot 2023-08-07 12:23:08 +02:00 committed by GitHub
commit c3cab72065
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -382,6 +382,8 @@ func copyToContainer(container string, containerPath string, hostPath string) er
if err != nil { if err != nil {
return err return err
} }
defer os.Remove(tmpFile.Name())
_, err = io.Copy(tmpFile, os.Stdin) _, err = io.Copy(tmpFile, os.Stdin)
if err != nil { if err != nil {
return err return err
@ -389,6 +391,7 @@ func copyToContainer(container string, containerPath string, hostPath string) er
if err = tmpFile.Close(); err != nil { if err = tmpFile.Close(); err != nil {
return err return err
} }
if !archive.IsArchivePath(tmpFile.Name()) { if !archive.IsArchivePath(tmpFile.Name()) {
return errors.New("source must be a (compressed) tar archive when copying from stdin") return errors.New("source must be a (compressed) tar archive when copying from stdin")
} }