mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
daemon/export: Stop when context is canceled
Close archive when context is done - this makes the cancellation actually stop the export instead of continuing it regardless if the client still expects the data. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
@@ -71,11 +71,17 @@ func (daemon *Daemon) containerExport(ctx context.Context, ctr *container.Contai
|
||||
return err
|
||||
}
|
||||
|
||||
if err := ctx.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
context.AfterFunc(ctx, func() {
|
||||
_ = archv.Close()
|
||||
})
|
||||
|
||||
// Stream the entire contents of the container (basically a volatile snapshot)
|
||||
if _, err := io.Copy(out, archv); err != nil {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return errdefs.Cancelled(err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user