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)
| 489 | // By default, only one ref is returned, unless the server has advertised |
| 490 | // that it has indexes calculated for other hash functions. |
| 491 | func (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. |
no test coverage detected