(ctx context.Context, path string)
| 14 | ) |
| 15 | |
| 16 | func 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 | |
| 39 | func Remove(ctx context.Context, path string) error { |
| 40 | user := ctx.Value(conf.UserKey).(*model.User) |
no test coverage detected