MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / Mkdir

Function Mkdir

server/ftp/fsmanage.go:16–37  ·  view source on GitHub ↗
(ctx context.Context, path string)

Source from the content-addressed store, hash-verified

14)
15
16func Mkdir(ctx context.Context, path string) error {
17 user := ctx.Value(conf.UserKey).(*model.User)
18 if !user.CanFTPManage() {
19 return errs.PermissionDenied
20 }
21 reqPath, err := user.JoinPath(path)
22 if err != nil {
23 return err
24 }
25 parentPath := stdpath.Dir(reqPath)
26 parentMeta, err := op.GetNearestMeta(parentPath)
27 if err != nil && !errors.Is(errors.Cause(err), errs.MetaNotFound) {
28 return err
29 }
30 if !user.CanWriteContent() && !common.CanWriteContentBypassUserPerms(parentMeta, parentPath) {
31 return errs.PermissionDenied
32 }
33 if !common.CanWrite(user, parentMeta, parentPath) {
34 return errs.PermissionDenied
35 }
36 return fs.MakeDir(ctx, reqPath)
37}
38
39func Remove(ctx context.Context, path string) error {
40 user := ctx.Value(conf.UserKey).(*model.User)

Callers 1

MkdirMethod · 0.70

Calls 7

GetNearestMetaFunction · 0.92
CanWriteFunction · 0.92
MakeDirFunction · 0.92
CanFTPManageMethod · 0.80
JoinPathMethod · 0.80
CanWriteContentMethod · 0.80

Tested by

no test coverage detected