code: func (c *Client) fileMapFromDuplicate(ctx context.Context, fileMap *schema.Builder, wholeRef []blob.Ref) (blob.Ref, error) {
  	dupFileRef, err := c.SearchExistingFileSchema(ctx, wholeRef...)
  	if err != nil {
  		return blob.Ref{}, err
  	}
  	if !dupFileRef.Valid() {
  		// because SearchExistingFileSchema returns blob.Ref{}, nil when file is not found.
  		return blob.Ref{}, nil
  	}
  	dupMap, err := c.FetchSchemaBlob(ctx, dupFileRef)
  	if err != nil {
  		return blob.Ref{}, fmt.Errorf("could not find existing file blob for wholeRef %q: %v", wholeRef, err)
  	}
  	fileMap.PopulateParts(dupMap.PartsSize(), dupMap.ByteParts())
  	json, err := fileMap.JSON()
  	if err != nil {
  		return blob.Ref{}, fmt.Errorf("could not write file map for wholeRef %q: %v", wholeRef, err)
  	}
  	bref := blob.RefFromString(json)
  	if bref == dupFileRef {
  		// Unchanged (same filename, modtime, JSON serialization, etc)
  		// Different signer (e.g. existing file has a sha1 signer, and
  		// we're now using a sha224 signer) means we upload a new file schema.
  		return dupFileRef, nil
  	}
  	sbr, err := c.ReceiveBlob(ctx, bref, strings.NewReader(json))
  	if err != nil {
  		return blob.Ref{}, err
  	}
  	return sbr.Ref, nil
  }
docs: // fileMapFromDuplicate queries the server's search interface for an
  // existing file blob for the file contents any of wholeRef.
  // If the server has it, it's validated, and then fileMap (which must
  // already be partially populated) has its "parts" field populated,
  // and then fileMap is uploaded (if necessary).
  // If no file blob is found, a zero blob.Ref (and no error) is returned.