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

Function uploadAuth

server/ftp/fsup.go:34–51  ·  view source on GitHub ↗
(ctx context.Context, path string)

Source from the content-addressed store, hash-verified

32}
33
34func uploadAuth(ctx context.Context, path string) error {
35 user := ctx.Value(conf.UserKey).(*model.User)
36 if !user.CanFTPManage() {
37 return errs.PermissionDenied
38 }
39 parentPath := stdpath.Dir(path)
40 parentMeta, err := op.GetNearestMeta(parentPath)
41 if err != nil && !errors.Is(errors.Cause(err), errs.MetaNotFound) {
42 return err
43 }
44 if !user.CanWriteContent() && !common.CanWriteContentBypassUserPerms(parentMeta, parentPath) {
45 return errs.PermissionDenied
46 }
47 if !common.CanWrite(user, parentMeta, parentPath) {
48 return errs.PermissionDenied
49 }
50 return nil
51}
52
53func OpenUpload(ctx context.Context, path string, trunc bool) (*FileUploadProxy, error) {
54 err := uploadAuth(ctx, path)

Callers 2

OpenUploadFunction · 0.85
OpenUploadWithLengthFunction · 0.85

Calls 5

GetNearestMetaFunction · 0.92
CanWriteFunction · 0.92
CanFTPManageMethod · 0.80
CanWriteContentMethod · 0.80

Tested by

no test coverage detected