diff --git a/backend/app/service/file.go b/backend/app/service/file.go index 2bbbd497d..4bdf2d9a7 100644 --- a/backend/app/service/file.go +++ b/backend/app/service/file.go @@ -4,6 +4,8 @@ import ( "fmt" "github.com/1Panel-dev/1Panel/backend/app/dto/request" "github.com/1Panel-dev/1Panel/backend/app/dto/response" + "github.com/1Panel-dev/1Panel/backend/buserr" + "github.com/1Panel-dev/1Panel/backend/constant" "io/fs" "os" "path/filepath" @@ -57,7 +59,6 @@ func (f FileService) GetFileTree(op request.FileOption) ([]response.FileTree, er } func (f FileService) Create(op request.FileCreate) error { - fo := files.NewFileOp() if fo.Stat(op.Path) { return errors.New("file is exist") @@ -154,6 +155,10 @@ func (f FileService) Wget(w request.FileWget) (string, error) { func (f FileService) MvFile(m request.FileMove) error { fo := files.NewFileOp() + if !fo.Stat(m.NewPath) { + return buserr.New(constant.ErrPathNotFound) + } + if m.Type == "cut" { return fo.Cut(m.OldPaths, m.NewPath) } diff --git a/backend/constant/errs.go b/backend/constant/errs.go index e4e08f99b..a4a58ce4b 100644 --- a/backend/constant/errs.go +++ b/backend/constant/errs.go @@ -70,3 +70,8 @@ var ( ErrAccountCannotDelete = "ErrAccountCannotDelete" ErrSSLApply = "ErrSSLApply" ) + +//file +var ( + ErrPathNotFound = "ErrPathNotFound" +) diff --git a/backend/i18n/lang/en.yaml b/backend/i18n/lang/en.yaml index 827cb2613..0198e8eba 100644 --- a/backend/i18n/lang/en.yaml +++ b/backend/i18n/lang/en.yaml @@ -23,10 +23,10 @@ ErrAppRequired: "{{ .detail }} app is required" ErrNotInstall: "App not installed" ErrPortInOtherApp: "{{ .port }} port already in use by {{ .apps }}" - #file ErrFileCanNotRead: "File can not read" ErrFileToLarge: "file is too large" +ErrPathNotFound: "Path is not found" #website ErrDomainIsExist: "Domain is already exist" diff --git a/backend/i18n/lang/zh.yaml b/backend/i18n/lang/zh.yaml index d8e4a3b4a..22ce0905a 100644 --- a/backend/i18n/lang/zh.yaml +++ b/backend/i18n/lang/zh.yaml @@ -26,6 +26,7 @@ ErrPortInOtherApp: "{{ .port }} 端口已被 {{ .apps }}占用!" #file ErrFileCanNotRead: "此文件不支持预览" ErrFileToLarge: "文件超过10M,无法打开" +ErrPathNotFound: "目录不存在" #website ErrDomainIsExist: "域名已存在" diff --git a/frontend/components.d.ts b/frontend/components.d.ts index b987f0e7d..18da02c96 100644 --- a/frontend/components.d.ts +++ b/frontend/components.d.ts @@ -59,6 +59,7 @@ declare module 'vue' { ElRow: typeof import('element-plus/es')['ElRow'] ElScrollbar: typeof import('element-plus/es')['ElScrollbar'] ElSelect: typeof import('element-plus/es')['ElSelect'] + ElSpan: typeof import('element-plus/es')['ElSpan'] ElSubMenu: typeof import('element-plus/es')['ElSubMenu'] ElSwitch: typeof import('element-plus/es')['ElSwitch'] ElTable: typeof import('element-plus/es')['ElTable'] diff --git a/frontend/src/views/app-store/installed/update/index.vue b/frontend/src/views/app-store/installed/update/index.vue index 85ef2f666..c0dd53613 100644 --- a/frontend/src/views/app-store/installed/update/index.vue +++ b/frontend/src/views/app-store/installed/update/index.vue @@ -1,5 +1,5 @@