修复PathMover.moveContent问题

This commit is contained in:
Looly
2024-06-17 10:05:29 +08:00
parent c8a1d67726
commit 69b3d4565c
2 changed files with 4 additions and 8 deletions

View File

@@ -130,19 +130,14 @@ public class PathMover {
*/
public Path moveContent() {
final Path src = this.src;
final Path target = this.target;
if (PathUtil.isExistsAndNotDirectory(target, false)) {
// 文件移动调用move方法
return move();
}
final Path target = this.target;
if (PathUtil.isExistsAndNotDirectory(target, false)) {
// 目标不能为文件
throw new IllegalArgumentException("Can not move dir content to a file");
}
// issue#2893 target 不存在导致NoSuchFileException
if (PathUtil.equals(src, target)) {
if (Files.exists(target) && PathUtil.equals(src, target)) {
// issue#2845当用户传入目标路径与源路径一致时直接返回否则会导致删除风险。
return target;
}