diff --git a/docs/debugging/s3-check-md5/main.go b/docs/debugging/s3-check-md5/main.go index ec257d5ee..ae4fb6a93 100644 --- a/docs/debugging/s3-check-md5/main.go +++ b/docs/debugging/s3-check-md5/main.go @@ -127,7 +127,7 @@ func main() { // List all objects from a bucket-name with a matching prefix. for object := range s3Client.ListObjects(context.Background(), bucket, opts) { if object.Err != nil { - log.Fatalln("LIST error:", object.Err) + log.Println("LIST error:", object.Err) continue } if object.IsDeleteMarker { @@ -162,6 +162,7 @@ func main() { } var partsMD5Sum [][]byte + var failedMD5 bool for p := 1; p <= parts; p++ { opts := minio.GetObjectOptions{ VersionID: object.VersionID, @@ -170,16 +171,23 @@ func main() { obj, err := s3Client.GetObject(context.Background(), bucket, object.Key, opts) if err != nil { log.Println("GET", bucket, object.Key, object.VersionID, "=>", err) - continue + failedMD5 = true + break } h := md5.New() if _, err := io.Copy(h, obj); err != nil { log.Println("MD5 calculation error:", bucket, object.Key, object.VersionID, "=>", err) - continue + failedMD5 = true + break } partsMD5Sum = append(partsMD5Sum, h.Sum(nil)) } + if failedMD5 { + log.Println("CORRUPTED object:", bucket, object.Key, object.VersionID) + continue + } + corrupted := false if !multipart { md5sum := fmt.Sprintf("%x", partsMD5Sum[0])