MCPcopy
hub / github.com/kopia/kopia / handleWriteContentRequest

Function handleWriteContentRequest

internal/server/grpc_session.go:279–304  ·  view source on GitHub ↗
(ctx context.Context, dw repo.DirectRepositoryWriter, authz auth.AuthorizationInfo, req *grpcapi.WriteContentRequest)

Source from the content-addressed store, hash-verified

277}
278
279func handleWriteContentRequest(ctx context.Context, dw repo.DirectRepositoryWriter, authz auth.AuthorizationInfo, req *grpcapi.WriteContentRequest) *grpcapi.SessionResponse {
280 ctx, span := tracer.Start(ctx, "GRPCSession.WriteContent")
281 defer span.End()
282
283 if authz.ContentAccessLevel() < auth.AccessLevelAppend {
284 return accessDeniedResponse()
285 }
286
287 if strings.HasPrefix(req.GetPrefix(), manifest.ContentPrefix) {
288 // it's not allowed to create contents prefixed with 'm' since those could be mistaken for manifest contents.
289 return accessDeniedResponse()
290 }
291
292 contentID, err := dw.ContentManager().WriteContent(ctx, gather.FromSlice(req.GetData()), content.IDPrefix(req.GetPrefix()), compression.HeaderID(req.GetCompression()))
293 if err != nil {
294 return errorResponse(err)
295 }
296
297 return &grpcapi.SessionResponse{
298 Response: &grpcapi.SessionResponse_WriteContent{
299 WriteContent: &grpcapi.WriteContentResponse{
300 ContentId: contentID.String(),
301 },
302 },
303 }
304}
305
306func handleFlushRequest(ctx context.Context, dw repo.DirectRepositoryWriter, authz auth.AuthorizationInfo, _ *grpcapi.FlushRequest) *grpcapi.SessionResponse {
307 if authz.ContentAccessLevel() < auth.AccessLevelAppend {

Callers 1

handleSessionRequestMethod · 0.85

Calls 13

FromSliceFunction · 0.92
HeaderIDTypeAlias · 0.92
accessDeniedResponseFunction · 0.85
errorResponseFunction · 0.85
HasPrefixMethod · 0.80
GetPrefixMethod · 0.80
GetCompressionMethod · 0.80
StartMethod · 0.65
ContentAccessLevelMethod · 0.65
WriteContentMethod · 0.65
ContentManagerMethod · 0.65
GetDataMethod · 0.45

Tested by

no test coverage detected