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

Method CreateNode

data/source/objects/handler.go:169–189  ·  view source on GitHub ↗
(ctx context.Context, request *tree.CreateNodeRequest)

Source from the content-addressed store, hash-verified

167}
168
169func (t *FsBrowser) CreateNode(ctx context.Context, request *tree.CreateNodeRequest) (*tree.CreateNodeResponse, error) {
170 fs, _ := t.getFS(ctx)
171 response := &tree.CreateNodeResponse{}
172 p := filesystem.ToFilePath(request.Node.Path)
173 if request.Node.IsLeaf() {
174 if file, e := fs.Create(p); e != nil {
175 return nil, e
176 } else {
177 fileInfo, _ := file.Stat()
178 response.Node = t.FileInfoToNode(request.Node.Path, fileInfo)
179 }
180 } else {
181 if e := fs.MkdirAll(p, 0755); e != nil {
182 return nil, e
183 } else {
184 fileInfo, _ := fs.Stat(p)
185 response.Node = t.FileInfoToNode(request.Node.Path, fileInfo)
186 }
187 }
188 return response, nil
189}
190
191func (t *FsBrowser) UpdateNode(ctx context.Context, request *tree.UpdateNodeRequest) (*tree.UpdateNodeResponse, error) {
192 return nil, errors.WithStack(errors.StatusNotImplemented)

Callers

nothing calls this directly

Calls 6

getFSMethod · 0.95
FileInfoToNodeMethod · 0.95
ToFilePathFunction · 0.92
IsLeafMethod · 0.65
CreateMethod · 0.45
StatMethod · 0.45

Tested by

no test coverage detected