(ctx context.Context, contentID content.ID, data []byte, prefix content.IDPrefix, comp compression.HeaderID)
| 721 | } |
| 722 | |
| 723 | func (r *grpcRepositoryClient) doWriteAsync(ctx context.Context, contentID content.ID, data []byte, prefix content.IDPrefix, comp compression.HeaderID) error { |
| 724 | // if content is large enough, perform existence check on the server, |
| 725 | // for small contents we skip the check, since the server-side existence |
| 726 | // check is fast and we avoid double round trip. |
| 727 | if len(data) >= writeContentCheckExistenceAboveSize { |
| 728 | if _, err := r.ContentInfo(ctx, contentID); err == nil { |
| 729 | // content already exists |
| 730 | return nil |
| 731 | } |
| 732 | } |
| 733 | |
| 734 | r.opt.OnUpload(int64(len(data))) |
| 735 | |
| 736 | if _, err := inSessionWithoutRetry(ctx, r, func(ctx context.Context, sess *grpcInnerSession) (content.ID, error) { |
| 737 | sess.writeContentAsyncAndVerify(ctx, contentID, data, prefix, comp, r.asyncWritesWG) |
| 738 | return contentID, nil |
| 739 | }); err != nil { |
| 740 | return err |
| 741 | } |
| 742 | |
| 743 | if prefix != "" { |
| 744 | // add all prefixed contents to the cache. |
| 745 | r.contentCache.Put(ctx, contentID.String(), gather.FromSlice(data)) |
| 746 | } |
| 747 | |
| 748 | return nil |
| 749 | } |
| 750 | |
| 751 | func (r *grpcRepositoryClient) WriteContent(ctx context.Context, data gather.Bytes, prefix content.IDPrefix, comp compression.HeaderID) (content.ID, error) { |
| 752 | if err := prefix.ValidateSingle(); err != nil { |
no test coverage detected