mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
修复PathMover.moveContent问题
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user