CreateNode creates directly in index, but make sure not to override
(ctx context.Context, in *tree.CreateNodeRequest, opts ...grpc.CallOption)
| 64 | |
| 65 | // CreateNode creates directly in index, but make sure not to override |
| 66 | func (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 | |
| 85 | func (f *FlatStorageHandler) DeleteNode(ctx context.Context, in *tree.DeleteNodeRequest, opts ...grpc.CallOption) (*tree.DeleteNodeResponse, error) { |
| 86 | isFlat := nodes.IsFlatStorage(ctx, "in") |
nothing calls this directly
no test coverage detected