Browse Source

fix: 解决部分情况下文件移动失败的问题 (#2752)

Refs https://github.com/1Panel-dev/1Panel/issues/1095
pull/2756/head
zhengkunwang 1 year ago committed by GitHub
parent
commit
94ca229e71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      backend/app/service/file.go
  2. 2
      backend/utils/files/file_op.go

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

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

Loading…
Cancel
Save