return error when io.Copy fails in Digest

Signed-off-by: Tariq Ibrahim <tariq181290@gmail.com>
pull/5790/head
Tariq Ibrahim 6 years ago
parent 9fb19967ba
commit ccf933b29a
No known key found for this signature in database
GPG Key ID: DFC94E4A008B908A

@ -405,7 +405,7 @@ func DigestFile(filename string) (string, error) {
func Digest(in io.Reader) (string, error) { func Digest(in io.Reader) (string, error) {
hash := crypto.SHA256.New() hash := crypto.SHA256.New()
if _, err := io.Copy(hash, in); err != nil { if _, err := io.Copy(hash, in); err != nil {
return "", nil return "", err
} }
return hex.EncodeToString(hash.Sum(nil)), nil return hex.EncodeToString(hash.Sum(nil)), nil
} }

Loading…
Cancel
Save