diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f79b734e..bafce5c44 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ # 🚀Changelog ------------------------------------------------------------------------------------------------------------- -# 5.8.29(2024-06-14) +# 5.8.29(2024-06-17) ### 🐣新特性 * 【core 】 DateUtil增加offsetYear方法 @@ -17,6 +17,7 @@ * 【core 】 修复VersionComparator传入空字符串报错问题(pr#3614@Github) * 【core 】 修复CaseInsensitiveLinkedMap顺序错误问题(issue#IA4K4F@Gitee) * 【core 】 修复DateUtil.offset空指针问题(issue#3617@Github) +* 【core 】 修复PathMover.moveContent问题(issue#IA5Q8D@Gitee) ------------------------------------------------------------------------------------------------------------- # 5.8.28(2024-05-29) diff --git a/hutool-core/src/main/java/cn/hutool/core/io/file/PathMover.java b/hutool-core/src/main/java/cn/hutool/core/io/file/PathMover.java index 9c0c0c037..489a946de 100755 --- a/hutool-core/src/main/java/cn/hutool/core/io/file/PathMover.java +++ b/hutool-core/src/main/java/cn/hutool/core/io/file/PathMover.java @@ -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; }