Fix race in ctr pull

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan
2018-05-01 16:59:27 -07:00
parent e017143dde
commit f701b3b960
2 changed files with 20 additions and 10 deletions

View File

@@ -57,10 +57,20 @@ command. As part of this process, we do the following:
if ref == "" {
return fmt.Errorf("please provide an image reference to pull")
}
ctx, cancel := commands.AppContext(context)
client, ctx, cancel, err := commands.NewClient(context)
if err != nil {
return err
}
defer cancel()
img, err := content.Fetch(ref, context)
ctx, done, err := client.WithLease(ctx)
if err != nil {
return err
}
defer done(ctx)
img, err := content.Fetch(ctx, client, ref, context)
if err != nil {
return err
}