mirror of https://github.com/docker/docs.git
Merge pull request #10445 from jlhawn/no_checksum_on_install
No longer compute checksum when installing images.
This commit is contained in:
commit
7b65de8771
|
@ -10,7 +10,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/archive"
|
"github.com/docker/docker/pkg/archive"
|
||||||
"github.com/docker/docker/pkg/tarsum"
|
|
||||||
"github.com/docker/docker/runconfig"
|
"github.com/docker/docker/runconfig"
|
||||||
"github.com/docker/docker/utils"
|
"github.com/docker/docker/utils"
|
||||||
)
|
)
|
||||||
|
@ -80,48 +79,15 @@ func LoadImage(root string) (*Image, error) {
|
||||||
|
|
||||||
// StoreImage stores file system layer data for the given image to the
|
// StoreImage stores file system layer data for the given image to the
|
||||||
// image's registered storage driver. Image metadata is stored in a file
|
// image's registered storage driver. Image metadata is stored in a file
|
||||||
// at the specified root directory. This function also computes a checksum
|
// at the specified root directory.
|
||||||
// of `layerData` if the image does not have one already.
|
func StoreImage(img *Image, layerData archive.ArchiveReader, root string) (err error) {
|
||||||
func StoreImage(img *Image, layerData archive.ArchiveReader, root string) error {
|
// Store the layer. If layerData is not nil, unpack it into the new layer
|
||||||
// Store the layer
|
|
||||||
var (
|
|
||||||
size int64
|
|
||||||
err error
|
|
||||||
driver = img.graph.Driver()
|
|
||||||
layerTarSum tarsum.TarSum
|
|
||||||
)
|
|
||||||
|
|
||||||
// If layerData is not nil, unpack it into the new layer
|
|
||||||
if layerData != nil {
|
if layerData != nil {
|
||||||
// If the image doesn't have a checksum, we should add it. The layer
|
if img.Size, err = img.graph.Driver().ApplyDiff(img.ID, img.Parent, layerData); err != nil {
|
||||||
// checksums are verified when they are pulled from a remote, but when
|
|
||||||
// a container is committed it should be added here. Also ensure that
|
|
||||||
// the stored checksum has the latest version of tarsum (assuming we
|
|
||||||
// are using tarsum).
|
|
||||||
if tarsum.VersionLabelForChecksum(img.Checksum) != tarsum.Version1.String() {
|
|
||||||
// Either there was no checksum or it's not a tarsum.v1
|
|
||||||
layerDataDecompressed, err := archive.DecompressStream(layerData)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer layerDataDecompressed.Close()
|
|
||||||
|
|
||||||
if layerTarSum, err = tarsum.NewTarSum(layerDataDecompressed, true, tarsum.Version1); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if size, err = driver.ApplyDiff(img.ID, img.Parent, layerTarSum); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
img.Checksum = layerTarSum.Sum(nil)
|
|
||||||
} else if size, err = driver.ApplyDiff(img.ID, img.Parent, layerData); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
img.Size = size
|
|
||||||
if err := img.SaveSize(root); err != nil {
|
if err := img.SaveSize(root); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue