mirror of https://github.com/docker/docs.git
Merge pull request #258 from mtrmac/unused-sha256
Don't compute an unnecessary cryptographic hash
This commit is contained in:
commit
ab6637934d
|
@ -405,10 +405,12 @@ func (c *Client) downloadSigned(role string, size int64, expectedSha256 []byte)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
if expectedSha256 != nil {
|
||||||
genHash := sha256.Sum256(raw)
|
genHash := sha256.Sum256(raw)
|
||||||
if expectedSha256 != nil && !bytes.Equal(genHash[:], expectedSha256) {
|
if !bytes.Equal(genHash[:], expectedSha256) {
|
||||||
return nil, nil, ErrChecksumMismatch{role: role}
|
return nil, nil, ErrChecksumMismatch{role: role}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
s := &data.Signed{}
|
s := &data.Signed{}
|
||||||
err = json.Unmarshal(raw, s)
|
err = json.Unmarshal(raw, s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue