storage/storage_image.go
func (s *storageImageSource) getSize() (int64, error) {
	var sum int64
	// Size up the data blobs.
	dataNames, err := s.imageRef.transport.store.ListImageBigData(s.image.ID)
	if err != nil {
		return -1, errors.Wrapf(err, "error reading image %q", s.image.ID)
	}
	for _, dataName := range dataNames {
		bigSize, err := s.imageRef.transport.store.ImageBigDataSize(s.image.ID, dataName)
		if err != nil {
			return -1, errors.Wrapf(err, "error reading data blob size %q for %q", dataName, s.image.ID)
		}
		sum += bigSize
	}
	// Add the signature sizes.
	for _, sigSize := range s.SignatureSizes {
		sum += int64(sigSize)
	}
	// Walk the layer list.
	layerID := s.image.TopLayer
	for layerID != "" {
		layer, err := s.imageRef.transport.store.Layer(layerID)
		if err != nil {
			return -1, err
		}
		if layer.UncompressedDigest == "" || layer.UncompressedSize < 0 {
			return -1, errors.Errorf("size for layer %q is unknown, failing getSize()", layerID)
		}
		sum += layer.UncompressedSize
		if layer.Parent == "" {
			break
		}
		layerID = layer.Parent
	}
	return sum, nil
}
func (s *storageImageSource) getSize() (int64, error) {
	var sum int64
	// Size up the data blobs.
	dataNames, err := s.imageRef.transport.store.ListImageBigData(s.image.ID)
	if err != nil {
		return -1, errors.Wrapf(err, "error reading image %q", s.image.ID)
	}
	for _, dataName := range dataNames {
		bigSize, err := s.imageRef.transport.store.ImageBigDataSize(s.image.ID, dataName)
		if err != nil {
			return -1, errors.Wrapf(err, "error reading data blob size %q for %q", dataName, s.image.ID)
		}
		sum += bigSize
	}
	// Add the signature sizes.
	for _, sigSize := range s.SignatureSizes {
		sum += int64(sigSize)
	}
	// Walk the layer list.
	layerID := s.image.TopLayer
	for layerID != "" {
		layer, err := s.imageRef.transport.store.Layer(layerID)
		if err != nil {
			return -1, err
		}
		if layer.UncompressedDigest == "" || layer.UncompressedSize < 0 {
			return -1, errors.Errorf("size for layer %q is unknown, failing getSize()", layerID)
		}
		sum += layer.UncompressedSize
		if layer.Parent == "" {
			break
		}
		layerID = layer.Parent
	}
	return sum, nil
}
func ( s * storageImageSource ) getSize ( ) ( int64 , error ) { var sum int64 // Size up the data blobs. dataNames , err := s . imageRef . transport . store . ListImageBigData ( s . image . ID ) if err != nil { return - 1 , errors . Wrapf ( err , " " , s . image . ID ) } for _ , dataName := range dataNames { bigSize , err := s . imageRef . transport . store . ImageBigDataSize ( s . image . ID , dataName ) if err != nil { return - 1 , errors . Wrapf ( err , " " , dataName , s . image . ID ) } sum += bigSize } // Add the signature sizes. for _ , sigSize := range s . SignatureSizes { sum += int64 ( sigSize ) } // Walk the layer list. layerID := s . image . TopLayer for layerID != " " { layer , err := s . imageRef . transport . store . Layer ( layerID ) if err != nil { return - 1 , err } if layer . UncompressedDigest == " " || layer . UncompressedSize < 0 { return - 1 , errors . Errorf ( " " , layerID ) } sum += layer . UncompressedSize if layer . Parent == " " { break } layerID = layer . Parent } return sum , nil }
// getSize() adds up the sizes of the image's data blobs (which includes the configuration blob), the
// signatures, and the uncompressed sizes of all of the image's layers.
getSize () adds up the sizes of the image s data blobs ( which includes the configuration blob ) the signatures and the uncompressed sizes of all of the image s layers .