Merge pull request #2036 from samt42/master

calculate sha256 file checksum by streaming
This commit is contained in:
KubeSphere CI Bot 2023-11-06 13:32:39 +08:00 committed by GitHub
commit 79d1949890
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -320,9 +320,9 @@ func sha256sum(path string) (string, error) {
}
defer file.Close()
data, err := io.ReadAll(file)
if err != nil {
hasher := sha256.New()
if _, err := io.Copy(hasher, file); err != nil {
return "", err
}
return fmt.Sprintf("%x", sha256.Sum256(data)), nil
return fmt.Sprintf("%x", hasher.Sum(nil)), nil
}