MCPcopy
hub / github.com/perkeep/perkeep / receive

Function receive

pkg/blobserver/receive.go:51–69  ·  view source on GitHub ↗
(ctx context.Context, dst BlobReceiver, br blob.Ref, src io.Reader, checkHash bool)

Source from the content-addressed store, hash-verified

49}
50
51func 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

Callers 2

ReceiveFunction · 0.85
ReceiveNoHashFunction · 0.85

Calls 4

GetHubFunction · 0.85
HashMethod · 0.65
ReceiveBlobMethod · 0.65
NotifyBlobReceivedMethod · 0.65

Tested by

no test coverage detected