pkg: storage: image: get size from image ID
@@ -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,9 +104,7 @@ 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])
+ ref, err := istorage.Transport.ParseStoreReference(svc.store, "@"+image.ID)
if err != nil {
return nil, err
}
@@ -112,8 +112,8 @@ func (svc *imageService) ListImages(systemContext *types.SystemContext, filter s
if err != nil {
return nil, err
}
- size = imageSize(img)
- }
+ size := imageSize(img)
+ img.Close()
results = append(results, ImageResult{
ID: image.ID,
Names: image.Names,
