Skip to content

Commit

Permalink
storageImageSource: add Size()
Browse files Browse the repository at this point in the history
Teach storageImageSource ImageSource objects to return their size, too.
A consumer that can do the type assertion can avoid some parsing that we
do when wrapping an ImageSource to create an Image if it was previously
only initializing the Image to get this one piece of information.

Signed-off-by: Nalin Dahyabhai <[email protected]>
  • Loading branch information
nalind committed Dec 11, 2017
1 parent b937756 commit d4b0a1c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions storage/storage_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,12 @@ func (s *storageImageSource) getSize() (int64, error) {
return sum, nil
}

// Size() 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.
func (s *storageImageSource) Size() (int64, error) {
return s.getSize()
}

// Size() returns the previously-computed size of the image, with no error.
func (s *storageImageCloser) Size() (int64, error) {
return s.size, nil
Expand Down

0 comments on commit d4b0a1c

Please sign in to comment.