fix: verify

This commit is contained in:
Hydraallen 2024-08-26 19:43:24 +08:00 committed by Boming Zhang
parent 63c8b418ec
commit 36b75ad578
GPG Key ID: D47306D7062CDA9D

View File

@ -37,7 +37,7 @@ func checkFileChecksum(rootDir, fileName, expectedChecksum string) (bool, string
}
if actualChecksum == expectedChecksum {
return true, fmt.Sprintf("Checksum for %s passed!", filePath)
return true, ""//fmt.Sprintf("Checksum for %s passed!", filePath)
} else {
return false, fmt.Sprintf("Checksum for %s failed. Expected %s, but got %s. Please revert the changes!", filePath, expectedChecksum, actualChecksum)
}
@ -55,7 +55,7 @@ func VerifyFiles(rootDir string,checkFileNameList string, checkFileSumList strin
// Check if the number of files matches the number of checksums
if len(fileNames) == 0 {
return fmt.Errorf("No checksum happened")
return nil//fmt.Errorf("No checksum happened")
}
if len(fileNames) != len(checkSums) {
@ -70,15 +70,17 @@ func VerifyFiles(rootDir string,checkFileNameList string, checkFileSumList strin
for i, fileName := range fileNames {
expectedChecksum := strings.TrimSpace(checkSums[i])
passed, message := checkFileChecksum(rootDir, fileName, expectedChecksum)
if message != "" {
return fmt.Errorf(message)
}
if !passed {
allPassed = false
errorMessages = append(errorMessages, message)
}
}
fmt.Printf("test")
if allPassed {
return fmt.Errorf("Congratulations! All checksums passed!")
return nil//fmt.Errorf("Congratulations! All checksums passed!")
} else {
return fmt.Errorf("Some checksums failed. Please review the errors below:")
for _, msg := range errorMessages {