From 94ca229e71b5f6e0bedf9a761708dd08e2fb26be Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Wed, 1 Nov 2023 11:51:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=83=85=E5=86=B5=E4=B8=8B=E6=96=87=E4=BB=B6=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98=20(#2752)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs https://github.com/1Panel-dev/1Panel/issues/1095 --- backend/app/service/file.go | 2 +- backend/utils/files/file_op.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/app/service/file.go b/backend/app/service/file.go index 0b92f940f..769ffd02d 100644 --- a/backend/app/service/file.go +++ b/backend/app/service/file.go @@ -231,7 +231,7 @@ func (f *FileService) MvFile(m request.FileMove) error { return buserr.New(constant.ErrPathNotFound) } for _, path := range m.OldPaths { - if path == m.NewPath || strings.Contains(m.NewPath, path) { + if path == m.NewPath || strings.Contains(m.NewPath, filepath.Clean(path)+"/") { return buserr.New(constant.ErrMovePathFailed) } } diff --git a/backend/utils/files/file_op.go b/backend/utils/files/file_op.go index bbca7b804..36e8c96c3 100644 --- a/backend/utils/files/file_op.go +++ b/backend/utils/files/file_op.go @@ -284,7 +284,7 @@ func (f FileOp) Cut(oldPaths []string, dst string) error { for _, p := range oldPaths { base := filepath.Base(p) dstPath := filepath.Join(dst, base) - if err := f.Fs.Rename(p, dstPath); err != nil { + if err := cmd.ExecCmd(fmt.Sprintf("mv %s %s", p, dstPath)); err != nil { return err } }