mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix bug
This commit is contained in:
parent
ec3a1b2519
commit
e2266f593f
@ -511,7 +511,8 @@ 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#2893 target 不存在导致NoSuchFileException
|
||||||
|
if(Files.exists(target) && equals(src, target)){
|
||||||
// issue#2845,当用户传入目标路径与源路径一致时,直接返回,否则会导致删除风险。
|
// issue#2845,当用户传入目标路径与源路径一致时,直接返回,否则会导致删除风险。
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
@ -78,4 +78,13 @@ public class PathUtilTest {
|
|||||||
final String contentType = FileUtil.getMimeType("a001.7z");
|
final String contentType = FileUtil.getMimeType("a001.7z");
|
||||||
Assert.assertEquals("application/x-7z-compressed", contentType);
|
Assert.assertEquals("application/x-7z-compressed", contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* issue#2893 target不存在空导致异常
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
@Ignore
|
||||||
|
public void moveTest2(){
|
||||||
|
PathUtil.move(Paths.get("D:\\project\\test1.txt"), Paths.get("D:\\project\\test2.txt"), false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user