mirror of
https://github.com/moby/moby.git
synced 2026-08-04 15:11:00 +00:00
daemon/images: rename err-returns to prevent shadowing
Prevent accidentally shadowing the error, which is used in a defer, and while at it, also fixed some linting warnings about unhandled errors. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -78,14 +78,14 @@ func (i *ImageService) CommitImage(ctx context.Context, c backend.CommitConfig)
|
||||
return id, nil
|
||||
}
|
||||
|
||||
func exportContainerRw(layerStore layer.Store, id, mountLabel string) (arch io.ReadCloser, err error) {
|
||||
func exportContainerRw(layerStore layer.Store, id, mountLabel string) (arch io.ReadCloser, retErr error) {
|
||||
rwlayer, err := layerStore.GetRWLayer(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func() {
|
||||
if err != nil {
|
||||
layerStore.ReleaseRWLayer(rwlayer)
|
||||
if retErr != nil {
|
||||
_, _ = layerStore.ReleaseRWLayer(rwlayer)
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -93,23 +93,21 @@ func exportContainerRw(layerStore layer.Store, id, mountLabel string) (arch io.R
|
||||
// mount the layer if needed. But the Diff() function for windows requests that
|
||||
// the layer should be mounted when calling it. So we reserve this mount call
|
||||
// until windows driver can implement Diff() interface correctly.
|
||||
_, err = rwlayer.Mount(mountLabel)
|
||||
if err != nil {
|
||||
if _, err := rwlayer.Mount(mountLabel); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
archive, err := rwlayer.TarStream()
|
||||
if err != nil {
|
||||
rwlayer.Unmount()
|
||||
_ = rwlayer.Unmount()
|
||||
return nil, err
|
||||
}
|
||||
return ioutils.NewReadCloserWrapper(archive, func() error {
|
||||
archive.Close()
|
||||
err = rwlayer.Unmount()
|
||||
layerStore.ReleaseRWLayer(rwlayer)
|
||||
return err
|
||||
}),
|
||||
nil
|
||||
_ = archive.Close()
|
||||
err := rwlayer.Unmount()
|
||||
_, _ = layerStore.ReleaseRWLayer(rwlayer)
|
||||
return err
|
||||
}), nil
|
||||
}
|
||||
|
||||
// CommitBuildStep is used by the builder to create an image for each step in
|
||||
|
||||
Reference in New Issue
Block a user