mirror of
https://github.com/moby/moby.git
synced 2026-01-11 10:41:43 +00:00
client: Client.ImageSave: close reader on context cancellation
Use a cancelReadCloser to automatically close the reader when the context is cancelled. Consumers are still recommended to manually close the reader, but the cancelReadCloser makes the Close idempotent. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -879,7 +879,7 @@ func (d *Daemon) LoadImage(ctx context.Context, t testing.TB, img string) {
|
||||
|
||||
reader, err := clientHost.ImageSave(ctx, []string{img})
|
||||
assert.NilError(t, err, "[%s] failed to download %s", d.id, img)
|
||||
defer reader.Close()
|
||||
defer func() { _ = reader.Close() }()
|
||||
|
||||
c := d.NewClientT(t)
|
||||
defer c.Close()
|
||||
|
||||
Reference in New Issue
Block a user