Fix content.ReaderAt close

Signed-off-by: Shiming Zhang <wzshiming@foxmail.com>
This commit is contained in:
Shiming Zhang
2021-05-08 12:30:16 +08:00
parent 01ca105b6a
commit b890f056e8
4 changed files with 8 additions and 1 deletions

View File

@@ -66,6 +66,7 @@ func (c *Client) Install(ctx context.Context, image Image, opts ...InstallOpts)
cr := content.NewReader(ra)
r, err := compression.DecompressStream(cr)
if err != nil {
ra.Close()
return err
}
if _, err := archive.Apply(ctx, path, r, archive.WithFilter(func(hdr *tar.Header) (bool, error) {
@@ -87,9 +88,11 @@ func (c *Client) Install(ctx context.Context, image Image, opts ...InstallOpts)
return result, nil
})); err != nil {
r.Close()
ra.Close()
return err
}
r.Close()
ra.Close()
}
return nil
}