MCPcopy
hub / github.com/perkeep/perkeep / filePart

Function filePart

pkg/schema/fileread_test.go:57–76  ·  view source on GitHub ↗

filePart returns a BytesPart that references a file JSON schema blob made of the provided content parts.

(cps []*BytesPart, skip uint64)

Source from the content-addressed store, hash-verified

55// filePart returns a BytesPart that references a file JSON schema
56// blob made of the provided content parts.
57func filePart(cps []*BytesPart, skip uint64) *BytesPart {
58 m := newBytes()
59 fileSize := int64(0)
60 cpl := []BytesPart{}
61 for _, cp := range cps {
62 fileSize += int64(cp.Size)
63 cpl = append(cpl, *cp)
64 }
65 err := m.PopulateParts(fileSize, cpl)
66 if err != nil {
67 panic(err)
68 }
69 json, err := m.JSON()
70 if err != nil {
71 panic(err)
72 }
73 tb := &test.Blob{Contents: json}
74 testFetcher.AddBlob(tb)
75 return &BytesPart{BytesRef: tb.BlobRef(), Size: uint64(fileSize) - skip, Offset: skip}
76}
77
78func all(blob *test.Blob) *BytesPart {
79 return part(blob, 0, uint64(blob.Size()))

Callers 1

fileread_test.goFile · 0.85

Calls 5

BlobRefMethod · 0.95
newBytesFunction · 0.85
PopulatePartsMethod · 0.80
AddBlobMethod · 0.80
JSONMethod · 0.45

Tested by

no test coverage detected