fix FileUtil.remove bug

This commit is contained in:
Looly 2020-04-23 12:01:53 +08:00
parent 74ba64c0c0
commit 368a5e4d1c
3 changed files with 10 additions and 2 deletions

View File

@ -10,6 +10,7 @@
* 【core 】 增加ThreadUtil.sleep和safeSleep的重载
* 【core 】 Sftp类增加toString方法issue#I1F2T4@Gitee
* 【core 】 修改FileUtil.size逻辑不存在的文件返回0
* 【extra 】 Sftp.ls遇到文件不存在返回空集合而非抛异常issue#844@Github
### Bug修复
* 【db 】 修复PageResult.isLast计算问题
@ -17,6 +18,7 @@
* 【db 】 修复Page.addOrder无效问题issue#I1F9MZ@Gitee
* 【json 】 修复JSONConvert转换日期空指针问题issue#I1F8M2@Gitee
* 【core 】 修复XML中带注释Xpath解析导致空指针问题issue#I1F2WI@Gitee
* 【core 】 修复FileUtil.rename原文件无扩展名多点的问题issue#839@Github
-------------------------------------------------------------------------------------------------------------
## 5.3.1 (2020-04-17)

View File

@ -1175,7 +1175,10 @@ public class FileUtil {
*/
public static File rename(File file, String newName, boolean isRetainExt, boolean isOverride) {
if (isRetainExt) {
newName = newName.concat(".").concat(FileUtil.extName(file));
final String extName = FileUtil.extName(file);
if(StrUtil.isNotBlank(extName)){
newName = newName.concat(".").concat(extName);
}
}
final Path path = file.toPath();
final CopyOption[] options = isOverride ? new CopyOption[]{StandardCopyOption.REPLACE_EXISTING} : new CopyOption[]{};

View File

@ -238,7 +238,10 @@ public class Sftp extends AbstractFtp {
return LsEntrySelector.CONTINUE;
});
} catch (SftpException e) {
throw new JschRuntimeException(e);
if(false == StrUtil.startWithIgnoreCase(e.getMessage(), "No such file")){
throw new JschRuntimeException(e);
}
// 文件不存在忽略
}
return fileNames;
}