Merge pull request #16774 from spowelljr/preventHashUpdate

CI: Fix cri-dockerd adding existing hash
pull/16777/head
Medya Ghazizadeh 2023-06-26 11:12:17 -07:00 committed by GitHub
commit 909f34924d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -122,6 +122,14 @@ func updateHashFiles(commit string) error {
}
func updateHashFile(filePath, commit string, shaSum [sha256.Size]byte) error {
b, err := os.ReadFile(filePath)
if err != nil {
return fmt.Errorf("failed to read hash file: %v", err)
}
if strings.Contains(string(b), commit) {
klog.Infof("hash file already contains %q", commit)
return nil
}
f, err := os.OpenFile(filePath, os.O_APPEND|os.O_WRONLY, 0644)
if err != nil {
return fmt.Errorf("failed to open hash file: %v", err)