diff --git a/app/http/controllers/file_controller.go b/app/http/controllers/file_controller.go index 02edde05..86e2d77c 100644 --- a/app/http/controllers/file_controller.go +++ b/app/http/controllers/file_controller.go @@ -353,7 +353,7 @@ func (r *FileController) Permission(ctx http.Context) http.Response { return sanitize } - if err := tools.Chmod(request.Path, request.Mode); err != nil { + if err := tools.Chmod(request.Path, os.FileMode(request.Mode)); err != nil { return Error(ctx, http.StatusInternalServerError, err.Error()) } if err := tools.Chown(request.Path, request.Owner, request.Group); err != nil { @@ -523,6 +523,6 @@ func (r *FileController) List(ctx http.Context) http.Response { // setPermission func (r *FileController) setPermission(path string, mode uint, owner, group string) { - _ = tools.Chmod(path, mode) + _ = tools.Chmod(path, os.FileMode(mode)) _ = tools.Chown(path, owner, group) } diff --git a/pkg/tools/system.go b/pkg/tools/system.go index 1fcbe544..b7b6f8c5 100644 --- a/pkg/tools/system.go +++ b/pkg/tools/system.go @@ -112,12 +112,12 @@ func Mkdir(path string, permission os.FileMode) error { } // Chmod 修改文件/目录权限 -func Chmod(path string, permission uint) error { +func Chmod(path string, permission os.FileMode) error { if env.IsWindows() { return errors.New("chmod is not supported on Windows") } - cmd := exec.Command("chmod", "-R", cast.ToString(permission), path) + cmd := exec.Command("chmod", "-R", permission.String(), path) return cmd.Run() }