9 // Compute the MD5 digest of a data block (consisting of buf1 + buf2 +
10 // all bytes readable from rdr). If all data is read successfully,
11 // return DiskHashError or CollisionError depending on whether it
12 // matches expectMD5. If an error occurs while reading, return that
15 // "content has expected MD5" is called a collision because this
16 // function is used in cases where we have another block in hand with
17 // the given MD5 but different content.
18 func collisionOrCorrupt(expectMD5 string, buf1, buf2 []byte, rdr io.Reader) error {
19 outcome := make(chan error)
20 data := make(chan []byte, 1)
26 if fmt.Sprintf("%x", h.Sum(nil)) == expectMD5 {
27 outcome <- CollisionError
29 outcome <- DiskHashError
37 for rdr != nil && err == nil {
38 buf := make([]byte, 1<<18)
40 n, err = rdr.Read(buf)
44 if rdr != nil && err != io.EOF {