diff --git a/CHANGELOG.md b/CHANGELOG.md index fd07095ad..244faf230 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ # 🚀Changelog ------------------------------------------------------------------------------------------------------------- -# 5.8.27(2024-02-26) +# 5.8.27(2024-03-05) ### 🐣新特性 * 【extra 】 FreemarkerEngine修改默认版本参数 @@ -10,6 +10,7 @@ * 【core 】 HexUtil#format方法增加prefix参数(issue#I93PU9@Gitee) ### 🐞Bug修复 +* 【core 】 修复PathMover对目标已存在且只读文件报错错误问题(issue#I95CLT@Gitee) ------------------------------------------------------------------------------------------------------------- # 5.8.26(2024-02-10) 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 926237426..9c0c0c037 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 @@ -101,9 +101,10 @@ public class PathMover { try { return Files.move(src, target, options); } catch (final IOException e) { - if (e instanceof FileAlreadyExistsException) { - // 目标文件已存在,直接抛出异常 - // issue#I4QV0L@Gitee + if (e instanceof FileAlreadyExistsException || e instanceof AccessDeniedException) { + // issue#I4QV0L@Gitee issue#I95CLT@Gitee + // FileAlreadyExistsException 目标已存在 + // AccessDeniedException 目标已存在且只读 throw new IORuntimeException(e); } // 移动失败,可能是跨分区移动导致的,采用递归移动方式