mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
修复PathMover.moveContent问题
This commit is contained in:
parent
c8a1d67726
commit
69b3d4565c
@ -2,7 +2,7 @@
|
|||||||
# 🚀Changelog
|
# 🚀Changelog
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
# 5.8.29(2024-06-14)
|
# 5.8.29(2024-06-17)
|
||||||
|
|
||||||
### 🐣新特性
|
### 🐣新特性
|
||||||
* 【core 】 DateUtil增加offsetYear方法
|
* 【core 】 DateUtil增加offsetYear方法
|
||||||
@ -17,6 +17,7 @@
|
|||||||
* 【core 】 修复VersionComparator传入空字符串报错问题(pr#3614@Github)
|
* 【core 】 修复VersionComparator传入空字符串报错问题(pr#3614@Github)
|
||||||
* 【core 】 修复CaseInsensitiveLinkedMap顺序错误问题(issue#IA4K4F@Gitee)
|
* 【core 】 修复CaseInsensitiveLinkedMap顺序错误问题(issue#IA4K4F@Gitee)
|
||||||
* 【core 】 修复DateUtil.offset空指针问题(issue#3617@Github)
|
* 【core 】 修复DateUtil.offset空指针问题(issue#3617@Github)
|
||||||
|
* 【core 】 修复PathMover.moveContent问题(issue#IA5Q8D@Gitee)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
# 5.8.28(2024-05-29)
|
# 5.8.28(2024-05-29)
|
||||||
|
@ -130,19 +130,14 @@ public class PathMover {
|
|||||||
*/
|
*/
|
||||||
public Path moveContent() {
|
public Path moveContent() {
|
||||||
final Path src = this.src;
|
final Path src = this.src;
|
||||||
|
final Path target = this.target;
|
||||||
if (PathUtil.isExistsAndNotDirectory(target, false)) {
|
if (PathUtil.isExistsAndNotDirectory(target, false)) {
|
||||||
// 文件移动调用move方法
|
// 文件移动调用move方法
|
||||||
return 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
|
// issue#2893 target 不存在导致NoSuchFileException
|
||||||
if (PathUtil.equals(src, target)) {
|
if (Files.exists(target) && PathUtil.equals(src, target)) {
|
||||||
// issue#2845,当用户传入目标路径与源路径一致时,直接返回,否则会导致删除风险。
|
// issue#2845,当用户传入目标路径与源路径一致时,直接返回,否则会导致删除风险。
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user