1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Some resource clean ups in archive

Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
This commit is contained in:
LK4D4 2014-07-14 21:11:48 +04:00
parent b93787e6e0
commit 66ccd55ed4

View file

@ -177,15 +177,15 @@ func addTarFile(path, name string, tw *tar.Writer) error {
}
if hdr.Typeflag == tar.TypeReg {
if file, err := os.Open(path); err != nil {
return err
} else {
_, err := io.Copy(tw, file)
file, err := os.Open(path)
if err != nil {
return err
}
if _, err := io.Copy(tw, file); err != nil {
file.Close()
return err
}
file.Close()
}
return nil
@ -544,19 +544,19 @@ func CopyFileWithTar(src, dst string) (err error) {
}
defer srcF.Close()
tw := tar.NewWriter(w)
hdr, err := tar.FileInfoHeader(srcSt, "")
if err != nil {
return err
}
hdr.Name = filepath.Base(dst)
tw := tar.NewWriter(w)
defer tw.Close()
if err := tw.WriteHeader(hdr); err != nil {
return err
}
if _, err := io.Copy(tw, srcF); err != nil {
return err
}
tw.Close()
return nil
})
defer func() {