diff --git a/pkg/storage/image.go b/pkg/storage/image.go index 29e3c746..32ca1513 100644 --- a/pkg/storage/image.go +++ b/pkg/storage/image.go @@ -90,10 +90,12 @@ func (svc *imageService) ListImages(systemContext *types.SystemContext, filter s if err != nil { return nil, err } + size := imageSize(img) + img.Close() results = append(results, ImageResult{ ID: image.ID, Names: image.Names, - Size: imageSize(img), + Size: size, }) } } else { @@ -102,18 +104,16 @@ func (svc *imageService) ListImages(systemContext *types.SystemContext, filter s return nil, err } for _, image := range images { - var size *uint64 - if len(image.Names) != 0 { - ref, err := svc.getRef(image.Names[0]) - if err != nil { - return nil, err - } - img, err := ref.NewImage(systemContext) - if err != nil { - return nil, err - } - size = imageSize(img) + ref, err := istorage.Transport.ParseStoreReference(svc.store, "@"+image.ID) + if err != nil { + return nil, err } + img, err := ref.NewImage(systemContext) + if err != nil { + return nil, err + } + size := imageSize(img) + img.Close() results = append(results, ImageResult{ ID: image.ID, Names: image.Names,