mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
修复FileUtil的rename在newName与原文件夹名称一样时,文件夹会被删除问题
This commit is contained in:
parent
d8edccf920
commit
b212fdc685
@ -14,6 +14,7 @@
|
|||||||
### 🐞Bug修复
|
### 🐞Bug修复
|
||||||
* 【core 】 修复HexUtil.isHexNumber()对"-"的判断问题(issue#2857@Github)
|
* 【core 】 修复HexUtil.isHexNumber()对"-"的判断问题(issue#2857@Github)
|
||||||
* 【core 】 修复FileTypeUtil判断wav后缀的录音文件类型不能匹配问题(pr#2834@Github)
|
* 【core 】 修复FileTypeUtil判断wav后缀的录音文件类型不能匹配问题(pr#2834@Github)
|
||||||
|
* 【core 】 修复FileUtil的rename在newName与原文件夹名称一样时,文件夹会被删除问题(issue#2845@Github)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -488,6 +488,11 @@ public class PathUtil {
|
|||||||
Assert.notNull(src, "Src path must be not null !");
|
Assert.notNull(src, "Src path must be not null !");
|
||||||
Assert.notNull(target, "Target path must be not null !");
|
Assert.notNull(target, "Target path must be not null !");
|
||||||
|
|
||||||
|
if(equals(src, target)){
|
||||||
|
// issue#2845,当用户传入目标路径与源路径一致时,直接返回,否则会导致删除风险。
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
if (isDirectory(target)) {
|
if (isDirectory(target)) {
|
||||||
target = target.resolve(src.getFileName());
|
target = target.resolve(src.getFileName());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user