pkg: storage: image: get size from image ID

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Antonio Murdaca 2017-09-07 17:09:04 +02:00 committed by Mrunal Patel
parent f9387aca28
commit 836919876a

View file

@ -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,