MCPcopy Create free account
hub / github.com/pydio/cells / CreateNode

Method CreateNode

common/nodes/core/handler-exec-flat.go:66–83  ·  view source on GitHub ↗

CreateNode creates directly in index, but make sure not to override

(ctx context.Context, in *tree.CreateNodeRequest, opts ...grpc.CallOption)

Source from the content-addressed store, hash-verified

64
65// CreateNode creates directly in index, but make sure not to override
66func (f *FlatStorageHandler) CreateNode(ctx context.Context, in *tree.CreateNodeRequest, opts ...grpc.CallOption) (*tree.CreateNodeResponse, error) {
67 if !nodes.IsFlatStorage(ctx, "in") || in.GetNode().IsLeaf() {
68 return f.Next.CreateNode(ctx, in, opts...)
69 }
70 if r, e := f.Next.ReadNode(ctx, &tree.ReadNodeRequest{Node: &tree.Node{Path: in.GetNode().GetPath()}}); e == nil && r.GetNode() != nil {
71 rNode := r.GetNode()
72 if rNode.IsLeaf() {
73 return nil, errors.WithMessage(errors.StatusForbidden, "trying to create a folder on top of an existing file")
74 }
75 rNode.MustSetMeta(common.MetaFlagIndexed, true)
76 return &tree.CreateNodeResponse{Node: rNode}, nil
77 }
78 cResp, cErr := nodes.GetSourcesPool(ctx).GetTreeClientWrite().CreateNode(ctx, in, opts...)
79 if cErr == nil && cResp.GetNode() != nil {
80 cResp.GetNode().MustSetMeta(common.MetaFlagIndexed, true)
81 }
82 return cResp, cErr
83}
84
85func (f *FlatStorageHandler) DeleteNode(ctx context.Context, in *tree.DeleteNodeRequest, opts ...grpc.CallOption) (*tree.DeleteNodeResponse, error) {
86 isFlat := nodes.IsFlatStorage(ctx, "in")

Callers

nothing calls this directly

Calls 9

IsFlatStorageFunction · 0.92
GetSourcesPoolFunction · 0.92
MustSetMetaMethod · 0.80
IsLeafMethod · 0.65
GetNodeMethod · 0.65
CreateNodeMethod · 0.65
ReadNodeMethod · 0.65
GetPathMethod · 0.65
GetTreeClientWriteMethod · 0.65

Tested by

no test coverage detected