Skip to content

Commit

Permalink
Merge pull request #2036 from samt42/master
Browse files Browse the repository at this point in the history
calculate sha256 file checksum by streaming
  • Loading branch information
ks-ci-bot authored Nov 6, 2023
2 parents 16e0a32 + 668ae5f commit 79d1949
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cmd/kk/pkg/files/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 79d1949

Please sign in to comment.