utils: close a couple of ReadClosers

utils.Tar() and utils.TarWithChroot() both return ReadClosers, but when
we called them from utils.TarToFilesystem() and utils.TarChrootToFilesystem()
respectively, they were not being closed.

[NO NEW TESTS NEEDED]

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
Nalin Dahyabhai
2023-11-28 15:45:14 -05:00
parent 443e779a1f
commit cf1ad300bb

View File

@ -77,6 +77,7 @@ func TarToFilesystem(source string, tarball *os.File) error {
if err != nil {
return err
}
defer tb.Close()
_, err = io.Copy(tarball, tb)
if err != nil {
return err
@ -98,6 +99,7 @@ func TarChrootToFilesystem(source string, tarball *os.File) error {
if err != nil {
return err
}
defer tb.Close()
_, err = io.Copy(tarball, tb)
if err != nil {
return err