@@ -80,8 +80,8 @@ func LoadImage(root string) (*Image, error) {
8080
8181// StoreImage stores file system layer data for the given image to the
8282// image's registered storage driver. Image metadata is stored in a file
83- // at the specified root directory. This function also computes the TarSum
84- // of `layerData` (currently using tarsum.dev) .
83+ // at the specified root directory. This function also computes a checksum
84+ // of `layerData` if the image does not have one already .
8585func StoreImage (img * Image , layerData archive.ArchiveReader , root string ) error {
8686 // Store the layer
8787 var (
@@ -95,15 +95,18 @@ func StoreImage(img *Image, layerData archive.ArchiveReader, root string) error
9595 if layerData != nil {
9696 // If the image doesn't have a checksum, we should add it. The layer
9797 // checksums are verified when they are pulled from a remote, but when
98- // a container is committed it should be added here.
99- if img .Checksum == "" {
98+ // a container is committed it should be added here. Also ensure that
99+ // the stored checksum has the latest version of tarsum (assuming we
100+ // are using tarsum).
101+ if tarsum .VersionLabelForChecksum (img .Checksum ) != tarsum .Version1 .String () {
102+ // Either there was no checksum or it's not a tarsum.v1
100103 layerDataDecompressed , err := archive .DecompressStream (layerData )
101104 if err != nil {
102105 return err
103106 }
104107 defer layerDataDecompressed .Close ()
105108
106- if layerTarSum , err = tarsum .NewTarSum (layerDataDecompressed , true , tarsum .VersionDev ); err != nil {
109+ if layerTarSum , err = tarsum .NewTarSum (layerDataDecompressed , true , tarsum .Version1 ); err != nil {
107110 return err
108111 }
109112
0 commit comments