mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-26 01:22:51 +00:00
check file sha256sum by streaming to save memory usage. good for machine with limited memory size.
This commit is contained in:
parent
f6211b5f76
commit
668ae5f099
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue