2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 10:17:17 +08:00

fix(文件): 统一copy的字段

This commit is contained in:
耗子
2024-05-21 21:32:54 +08:00
parent 3a5ff9179a
commit 5cd68fcdc3
2 changed files with 9 additions and 9 deletions

View File

@@ -210,7 +210,7 @@ func (r *FileController) Move(ctx http.Context) http.Response {
}
if tools.Exists(request.Target) && !ctx.Request().InputBool("force") {
return Error(ctx, http.StatusForbidden, "目标路径已存在,是否覆盖?")
return Error(ctx, http.StatusForbidden, "目标路径"+request.Target+"已存在")
}
if err := tools.Mv(request.Source, request.Target); err != nil {
@@ -239,15 +239,15 @@ func (r *FileController) Copy(ctx http.Context) http.Response {
return sanitize
}
if tools.Exists(request.New) && !ctx.Request().InputBool("force") {
return Error(ctx, http.StatusForbidden, "目标路径已存在,是否覆盖?")
if tools.Exists(request.Target) && !ctx.Request().InputBool("force") {
return Error(ctx, http.StatusForbidden, "目标路径"+request.Target+"已存在")
}
if err := tools.Cp(request.Old, request.New); err != nil {
if err := tools.Cp(request.Source, request.Target); err != nil {
return Error(ctx, http.StatusInternalServerError, err.Error())
}
r.setPermission(request.New, 0755, "www", "www")
r.setPermission(request.Source, 0755, "www", "www")
return Success(ctx, nil)
}

View File

@@ -6,8 +6,8 @@ import (
)
type Copy struct {
Old string `form:"old" json:"old"`
New string `form:"new" json:"new"`
Source string `form:"source" json:"source"`
Target string `form:"target" json:"target"`
}
func (r *Copy) Authorize(ctx http.Context) error {
@@ -16,8 +16,8 @@ func (r *Copy) Authorize(ctx http.Context) error {
func (r *Copy) Rules(ctx http.Context) map[string]string {
return map[string]string{
"old": `regex:^/[a-zA-Z0-9_.@#$%\-\s\[\]()]+(/[a-zA-Z0-9_.@#$%\-\s\[\]()]+)*$|path_exists`,
"new": `regex:^/[a-zA-Z0-9_.@#$%\-\s\[\]()]+(/[a-zA-Z0-9_.@#$%\-\s\[\]()]+)*$`,
"source": `regex:^/[a-zA-Z0-9_.@#$%\-\s\[\]()]+(/[a-zA-Z0-9_.@#$%\-\s\[\]()]+)*$|path_exists`,
"target": `regex:^/[a-zA-Z0-9_.@#$%\-\s\[\]()]+(/[a-zA-Z0-9_.@#$%\-\s\[\]()]+)*$`,
}
}