MCPcopy
hub / github.com/kopia/kopia / doWriteAsync

Method doWriteAsync

repo/grpc_repository_client.go:723–749  ·  view source on GitHub ↗
(ctx context.Context, contentID content.ID, data []byte, prefix content.IDPrefix, comp compression.HeaderID)

Source from the content-addressed store, hash-verified

721}
722
723func (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
751func (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 {

Callers 1

WriteContentMethod · 0.95

Calls 6

ContentInfoMethod · 0.95
FromSliceFunction · 0.92
inSessionWithoutRetryFunction · 0.85
PutMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected