MCPcopy
hub / github.com/perkeep/perkeep / wholeRef

Method wholeRef

pkg/client/upload.go:491–506  ·  view source on GitHub ↗

TODO(mpl): replace up.wholeFileDigest in pk-put with c.wholeRef maybe. wholeRef returns the blob ref(s) of the regular file's contents as if it were one entire blob (ignoring blob size limits). By default, only one ref is returned, unless the server has advertised that it has indexes calculated for

(contents io.Reader)

Source from the content-addressed store, hash-verified

489// By default, only one ref is returned, unless the server has advertised
490// that it has indexes calculated for other hash functions.
491func (c *Client) wholeRef(contents io.Reader) ([]blob.Ref, error) {
492 hasLegacySHA1, err := c.HasLegacySHA1()
493 if err != nil {
494 return nil, fmt.Errorf("cannot discover if server has legacy sha1: %v", err)
495 }
496 td := hashutil.NewTrackDigestReader(contents)
497 td.DoLegacySHA1 = hasLegacySHA1
498 if _, err := io.Copy(io.Discard, td); err != nil {
499 return nil, err
500 }
501 refs := []blob.Ref{blob.RefFromHash(td.Hash())}
502 if td.DoLegacySHA1 {
503 refs = append(refs, blob.RefFromHash(td.LegacySHA1Hash()))
504 }
505 return refs, nil
506}
507
508// fileMapFromDuplicate queries the server's search interface for an
509// existing file blob for the file contents any of wholeRef.

Callers 1

UploadFileMethod · 0.95

Calls 5

HasLegacySHA1Method · 0.95
HashMethod · 0.95
LegacySHA1HashMethod · 0.95
NewTrackDigestReaderFunction · 0.92
RefFromHashFunction · 0.92

Tested by

no test coverage detected