Skip to content

Commit 0c5444e

Browse files
committed
优化Ftp.download,返回false抛出异常(issue#3805@Github)
1 parent 7da0856 commit 0c5444e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
### 🐣新特性
88
* 【poi 】 优化ExcelWriter中使用比较器writer的方法,只对第一条数据进行排序(pr#3807@Github)
9+
* 【extra 】 优化Ftp.download,返回false抛出异常(issue#3805@Github)
910

1011
### 🐞Bug修复
1112
* 【crypto 】 修复JWTSignerUtil.createSigner中algorithmId未转换问题(issue#3806@Github)

hutool-extra/src/main/java/cn/hutool/extra/ftp/Ftp.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,16 +708,22 @@ public void download(String path, String fileName, OutputStream out, Charset fil
708708
if (null != fileNameCharset) {
709709
fileName = new String(fileName.getBytes(fileNameCharset), StandardCharsets.ISO_8859_1);
710710
}
711+
712+
boolean isSuccess;
711713
try {
712714
client.setFileType(FTPClient.BINARY_FILE_TYPE);
713-
client.retrieveFile(fileName, out);
715+
isSuccess = client.retrieveFile(fileName, out);
714716
} catch (IOException e) {
715717
throw new IORuntimeException(e);
716718
} finally {
717719
if (backToPwd) {
718720
cd(pwd);
719721
}
720722
}
723+
724+
if(false == isSuccess){
725+
throw new FtpException("retrieveFile return false");
726+
}
721727
}
722728

723729
/**

0 commit comments

Comments
 (0)