Skip to content

Commit 35378cd

Browse files
committed
fix(errmsg): export err to object consts
1 parent 9f4d88d commit 35378cd

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

internal/errs/object.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ var (
1111
ObjectAlreadyExists = errors.New("object already exists")
1212
NotFolder = errors.New("not a folder")
1313
NotFile = errors.New("not a file")
14+
IgnoredSystemFile = errors.New("system file upload ignored")
1415
)
1516

1617
func IsObjectNotFound(err error) bool {

server/ftp/fsup.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func uploadAuth(ctx context.Context, path string) error {
4141
}
4242
if !(common.CanAccess(user, meta, path, ctx.Value(conf.MetaPassKey).(string)) &&
4343
((user.CanFTPManage() && user.CanWrite()) || common.CanWrite(meta, stdpath.Dir(path)))) {
44-
return errs.PermissionDenied
44+
return errs.IgnoredSystemFile
4545
}
4646
return nil
4747
}
@@ -54,7 +54,7 @@ func OpenUpload(ctx context.Context, path string, trunc bool) (*FileUploadProxy,
5454
// Check if system file should be ignored
5555
_, name := stdpath.Split(path)
5656
if setting.GetBool(conf.IgnoreSystemFiles) && utils.IsSystemFile(name) {
57-
return nil, errs.PermissionDenied
57+
return nil, errs.IgnoredSystemFile
5858
}
5959
tmpFile, err := os.CreateTemp(conf.Conf.TempDir, "file-*")
6060
if err != nil {

server/s3/backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ func (b *s3Backend) PutObject(
289289
}
290290
// Check if system file should be ignored
291291
if setting.GetBool(conf.IgnoreSystemFiles) && utils.IsSystemFile(obj.Name) {
292-
return result, errors.New("system file upload ignored")
292+
return result, errs.IgnoredSystemFile
293293
}
294294
stream := &stream.FileStream{
295295
Obj: &obj,

server/webdav/webdav.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ func (h *Handler) handlePut(w http.ResponseWriter, r *http.Request) (status int,
361361
}
362362
// Check if system file should be ignored
363363
if setting.GetBool(conf.IgnoreSystemFiles) && utils.IsSystemFile(obj.Name) {
364-
return http.StatusForbidden, errors.New("system file upload ignored")
364+
return http.StatusForbidden, errs.IgnoredSystemFile
365365
}
366366
fsStream := &stream.FileStream{
367367
Obj: &obj,

0 commit comments

Comments
 (0)