Преглед на файлове

Fix ImageSummary.Size value

The prune PR changed the meaning of the file to mean "space on disk
only unique to this image", this PR revert this change.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
Kenfe-Mickael Laventure преди 8 години
родител
ревизия
be20dc15af
променени са 2 файла, в които са добавени 4 реда и са изтрити 8 реда
  1. 3 4
      cli/command/formatter/image.go
  2. 1 4
      daemon/images.go

+ 3 - 4
cli/command/formatter/image.go

@@ -226,8 +226,7 @@ func (c *imageContext) CreatedAt() string {
 
 func (c *imageContext) Size() string {
 	c.AddHeader(sizeHeader)
-	//NOTE: For backward compatibility we need to return VirtualSize
-	return units.HumanSizeWithPrecision(float64(c.i.VirtualSize), 3)
+	return units.HumanSizeWithPrecision(float64(c.i.Size), 3)
 }
 
 func (c *imageContext) Containers() string {
@@ -253,8 +252,8 @@ func (c *imageContext) SharedSize() string {
 
 func (c *imageContext) UniqueSize() string {
 	c.AddHeader(uniqueSizeHeader)
-	if c.i.Size == -1 {
+	if c.i.VirtualSize == -1 || c.i.SharedSize == -1 {
 		return "N/A"
 	}
-	return units.HumanSize(float64(c.i.Size))
+	return units.HumanSize(float64(c.i.VirtualSize - c.i.SharedSize))
 }

+ 1 - 4
daemon/images.go

@@ -210,7 +210,6 @@ func (daemon *Daemon) Images(imageFilters filters.Args, all bool, withExtraAttrs
 			rootFS := *img.RootFS
 			rootFS.DiffIDs = nil
 
-			newImage.Size = 0
 			newImage.SharedSize = 0
 			for _, id := range img.RootFS.DiffIDs {
 				rootFS.Append(id)
@@ -223,8 +222,6 @@ func (daemon *Daemon) Images(imageFilters filters.Args, all bool, withExtraAttrs
 
 				if layerRefs[chid] > 1 {
 					newImage.SharedSize += diffSize
-				} else {
-					newImage.Size += diffSize
 				}
 			}
 		}
@@ -323,7 +320,7 @@ func newImage(image *image.Image, virtualSize int64) *types.ImageSummary {
 	newImage.ParentID = image.Parent.String()
 	newImage.ID = image.ID().String()
 	newImage.Created = image.Created.Unix()
-	newImage.Size = -1
+	newImage.Size = virtualSize
 	newImage.VirtualSize = virtualSize
 	newImage.SharedSize = -1
 	newImage.Containers = -1