Skip to content

Commit

Permalink
Merge pull request moby#7331 from erikh/simplify_checksum
Browse files Browse the repository at this point in the history
Simplify utils.CheckSum.Read to use TeeReader instead
  • Loading branch information
tiborvass committed Jul 30, 2014
2 parents c3045f5 + ef6b78f commit a0338ff
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 26 deletions.
5 changes: 3 additions & 2 deletions registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
_ "crypto/sha512"
"crypto/tls"
"crypto/x509"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

Expand Down
24 changes: 0 additions & 24 deletions utils/checksum.go

This file was deleted.

0 comments on commit a0338ff

Please sign in to comment.