diff --git a/CHANGELOG.md b/CHANGELOG.md index aced465e1..608319048 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ ### 🐞Bug修复 * 【core 】 修复RobotUtil双击右键问题(pr#1721@Github) * 【core 】 修复FileTypeUtil判断wps修改过的xlsx误判为jar的问题(pr#380@Gitee) +* 【core 】 修复Sftp.isDir异常bug(pr#378@Gitee) ------------------------------------------------------------------------------------------------------------- diff --git a/hutool-extra/src/main/java/cn/hutool/extra/ssh/Sftp.java b/hutool-extra/src/main/java/cn/hutool/extra/ssh/Sftp.java index 2b630ab17..a38b0c897 100644 --- a/hutool-extra/src/main/java/cn/hutool/extra/ssh/Sftp.java +++ b/hutool-extra/src/main/java/cn/hutool/extra/ssh/Sftp.java @@ -337,6 +337,11 @@ public class Sftp extends AbstractFtp { try { sftpATTRS = this.channel.stat(dir); } catch (SftpException e) { + if(e.getMessage().contains("No such file")){ + // 文件不存在直接返回false + // pr#378@Gitee + return false; + } throw new FtpException(e); } return sftpATTRS.isDir();