Fix content.ReaderAt close
Signed-off-by: Shiming Zhang <wzshiming@foxmail.com>
This commit is contained in:
parent
01ca105b6a
commit
b890f056e8
@ -164,6 +164,7 @@ var diffCommand = cli.Command{
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer ra.Close()
|
||||
_, err = io.Copy(os.Stdout, content.NewReader(ra))
|
||||
|
||||
return err
|
||||
|
@ -780,6 +780,7 @@ func checkSmallBlob(ctx context.Context, t *testing.T, store content.Store) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer ra.Close()
|
||||
r := io.NewSectionReader(ra, 0, readSize)
|
||||
b, err := ioutil.ReadAll(r)
|
||||
if err != nil {
|
||||
|
@ -281,6 +281,7 @@ func resolveLayers(ctx context.Context, store content.Store, layerFiles []string
|
||||
}
|
||||
s, err := compression.DecompressStream(content.NewReader(ra))
|
||||
if err != nil {
|
||||
ra.Close()
|
||||
return nil, errors.Wrapf(err, "failed to detect compression for %q", layerFiles[i])
|
||||
}
|
||||
if s.GetCompression() == compression.Uncompressed {
|
||||
@ -292,6 +293,7 @@ func resolveLayers(ctx context.Context, store content.Store, layerFiles []string
|
||||
layers[i], err = compressBlob(ctx, store, s, ref, content.WithLabels(labels))
|
||||
if err != nil {
|
||||
s.Close()
|
||||
ra.Close()
|
||||
return nil, err
|
||||
}
|
||||
layers[i].MediaType = images.MediaTypeDockerSchema2LayerGzip
|
||||
@ -302,7 +304,7 @@ func resolveLayers(ctx context.Context, store content.Store, layerFiles []string
|
||||
layers[i].MediaType = images.MediaTypeDockerSchema2LayerGzip
|
||||
}
|
||||
s.Close()
|
||||
|
||||
ra.Close()
|
||||
}
|
||||
return layers, nil
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user