(ctx context.Context, dst BlobReceiver, br blob.Ref, src io.Reader, checkHash bool)
| 49 | } |
| 50 | |
| 51 | func receive(ctx context.Context, dst BlobReceiver, br blob.Ref, src io.Reader, checkHash bool) (sb blob.SizedRef, err error) { |
| 52 | src = io.LimitReader(src, MaxBlobSize) |
| 53 | if checkHash { |
| 54 | h := br.Hash() |
| 55 | if h == nil { |
| 56 | return sb, fmt.Errorf("invalid blob type %v; no registered hash function", br) |
| 57 | } |
| 58 | src = &checkHashReader{h, br, src, false} |
| 59 | } |
| 60 | sb, err = dst.ReceiveBlob(ctx, br, src) |
| 61 | if err != nil { |
| 62 | if checkHash && src.(*checkHashReader).corrupt { |
| 63 | err = ErrCorruptBlob |
| 64 | } |
| 65 | return |
| 66 | } |
| 67 | err = GetHub(dst).NotifyBlobReceived(sb) |
| 68 | return |
| 69 | } |
| 70 | |
| 71 | // checkHashReader is an io.Reader that wraps the src Reader but turns |
| 72 | // an io.EOF into an ErrCorruptBlob if the data read doesn't match the |
no test coverage detected