From 47261aa8cf7aadda67c2d554ee7985f0852d663e Mon Sep 17 00:00:00 2001 From: Erik Hollensbe Date: Wed, 30 Jul 2014 09:28:42 -0700 Subject: [PATCH] Remove CheckSum from utils; replace with a TeeReader Docker-DCO-1.1-Signed-off-by: Erik Hollensbe (github: erikh) --- docs/registry.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/registry.go b/docs/registry.go index 0d4f2b3c..9035ce90 100644 --- a/docs/registry.go +++ b/docs/registry.go @@ -6,6 +6,7 @@ import ( _ "crypto/sha512" "crypto/tls" "crypto/x509" + "encoding/hex" "encoding/json" "errors" "fmt" @@ -642,7 +643,7 @@ func (r *Registry) PushImageLayerRegistry(imgID string, layer io.Reader, registr h := sha256.New() h.Write(jsonRaw) h.Write([]byte{'\n'}) - checksumLayer := &utils.CheckSum{Reader: tarsumLayer, Hash: h} + checksumLayer := io.TeeReader(tarsumLayer, h) req, err := r.reqFactory.NewRequest("PUT", registry+"images/"+imgID+"/layer", checksumLayer) if err != nil { @@ -671,7 +672,7 @@ func (r *Registry) PushImageLayerRegistry(imgID string, layer io.Reader, registr return "", "", utils.NewHTTPRequestError(fmt.Sprintf("Received HTTP code %d while uploading layer: %s", res.StatusCode, errBody), res) } - checksumPayload = "sha256:" + checksumLayer.Sum() + checksumPayload = "sha256:" + hex.EncodeToString(h.Sum(nil)) return tarsumLayer.Sum(jsonRaw), checksumPayload, nil }