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 } }