MCPcopy
hub / github.com/perkeep/perkeep / ValidContents

Method ValidContents

pkg/blob/blob.go:95–106  ·  view source on GitHub ↗

ValidContents reports whether the hash of blob's content matches its reference.

(ctx context.Context)

Source from the content-addressed store, hash-verified

93// ValidContents reports whether the hash of blob's content matches
94// its reference.
95func (b *Blob) ValidContents(ctx context.Context) error {
96 mem, err := b.getMem(ctx)
97 if err != nil {
98 return err
99 }
100 h := b.ref.Hash()
101 h.Write(mem)
102 if !b.ref.HashMatches(h) {
103 return fmt.Errorf("blob contents don't match digest for ref %v", b.ref)
104 }
105 return nil
106}
107
108// IsUTF8 reports whether the blob is entirely UTF-8.
109func (b *Blob) IsUTF8(ctx context.Context) (bool, error) {

Callers

nothing calls this directly

Calls 4

getMemMethod · 0.95
HashMethod · 0.65
WriteMethod · 0.45
HashMatchesMethod · 0.45

Tested by

no test coverage detected