Use layer checksum if calculated during manifest creation

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
Derek McGowan 2015-01-27 10:21:35 -08:00
parent e15300b251
commit ab589b442d
1 changed files with 22 additions and 18 deletions

View File

@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"path"
log "github.com/Sirupsen/logrus" log "github.com/Sirupsen/logrus"
"github.com/docker/docker/engine" "github.com/docker/docker/engine"
@ -93,6 +92,8 @@ func (s *TagStore) newManifest(localName, remoteName, tag string) ([]byte, error
} }
} }
checksum := layer.Checksum
if tarsum.VersionLabelForChecksum(checksum) != tarsum.Version1.String() {
archive, err := layer.TarLayer() archive, err := layer.TarLayer()
if err != nil { if err != nil {
return nil, err return nil, err
@ -106,15 +107,18 @@ func (s *TagStore) newManifest(localName, remoteName, tag string) ([]byte, error
return nil, err return nil, err
} }
tarId := tarSum.Sum(nil) checksum = tarSum.Sum(nil)
}
manifest.FSLayers = append(manifest.FSLayers, &registry.FSLayer{BlobSum: tarId}) jsonData, err := layer.RawJson()
layersSeen[layer.ID] = true
jsonData, err := ioutil.ReadFile(path.Join(s.graph.Root, layer.ID, "json"))
if err != nil { if err != nil {
return nil, fmt.Errorf("Cannot retrieve the path for {%s}: %s", layer.ID, err) return nil, fmt.Errorf("Cannot retrieve the path for {%s}: %s", layer.ID, err)
} }
manifest.FSLayers = append(manifest.FSLayers, &registry.FSLayer{BlobSum: checksum})
layersSeen[layer.ID] = true
manifest.History = append(manifest.History, &registry.ManifestHistory{V1Compatibility: string(jsonData)}) manifest.History = append(manifest.History, &registry.ManifestHistory{V1Compatibility: string(jsonData)})
} }