Skip to content

Commit

Permalink
feat: hutool-extra ftp 保持 false == variable 的写法
Browse files Browse the repository at this point in the history
  • Loading branch information
xhzou committed Sep 26, 2022
1 parent 775caa9 commit 8bbe6bb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Expand Up @@ -163,13 +163,13 @@ public void mkDirs(String dir) {
if (StrUtil.isNotEmpty(s)) {
boolean exist = true;
try {
if (!cd(s)) {
if (false == cd(s)) {
exist = false;
}
} catch (FtpException e) {
exist = false;
}
if (!exist) {
if (false == exist) {
//目录不存在时创建
mkdir(s);
cd(s);
Expand Down
20 changes: 10 additions & 10 deletions hutool-extra/src/main/java/cn/hutool/extra/ftp/Ftp.java
Expand Up @@ -220,7 +220,7 @@ public Ftp init(FtpConfig config, FtpMode mode) {
throw new IORuntimeException(e);
}
final int replyCode = client.getReplyCode(); // 是否成功登录服务器
if (!FTPReply.isPositiveCompletion(replyCode)) {
if (false == FTPReply.isPositiveCompletion(replyCode)) {
try {
client.disconnect();
} catch (IOException e) {
Expand Down Expand Up @@ -355,7 +355,7 @@ public List<FTPFile> lsFiles(String path, Filter<FTPFile> filter) {
String fileName;
for (FTPFile ftpFile : ftpFiles) {
fileName = ftpFile.getName();
if (!StrUtil.equals(".", fileName) && !StrUtil.equals("..", fileName)) {
if (false == StrUtil.equals(".", fileName) && false == StrUtil.equals("..", fileName)) {
if (null == filter || filter.accept(ftpFile)) {
result.add(ftpFile);
}
Expand All @@ -376,7 +376,7 @@ public FTPFile[] lsFiles(String path) throws FtpException, IORuntimeException {
String pwd = null;
if (StrUtil.isNotBlank(path)) {
pwd = pwd();
if (!cd(path)) {
if (false == cd(path)) {
throw new FtpException("Change dir to [{}] error, maybe path not exist!", path);
}
}
Expand Down Expand Up @@ -440,7 +440,7 @@ public boolean delFile(String path) throws IORuntimeException {
final String pwd = pwd();
final String fileName = FileUtil.getName(path);
final String dir = StrUtil.removeSuffix(path, fileName);
if (!cd(dir)) {
if (false == cd(dir)) {
throw new FtpException("Change dir to [{}] error, maybe dir not exist!", path);
}

Expand Down Expand Up @@ -471,7 +471,7 @@ public boolean delDir(String dirPath) throws IORuntimeException {
childPath = StrUtil.format("{}/{}", dirPath, name);
if (ftpFile.isDirectory()) {
// 上级和本级目录除外
if (!".".equals(name) && !"..".equals(name)) {
if (false == ".".equals(name) && false == "..".equals(name)) {
delDir(childPath);
}
} else {
Expand Down Expand Up @@ -558,7 +558,7 @@ public boolean upload(String destPath, String fileName, InputStream fileStream)

if (StrUtil.isNotBlank(destPath)) {
mkDirs(destPath);
if (!cd(destPath)) {
if (false == cd(destPath)) {
throw new FtpException("Change dir to [{}] error, maybe dir not exist!", destPath);
}
}
Expand Down Expand Up @@ -651,9 +651,9 @@ public void recursiveDownloadFolder(String sourcePath, File destDir) {
srcFile = StrUtil.format("{}/{}", sourcePath, fileName);
destFile = FileUtil.file(destDir, fileName);

if (!ftpFile.isDirectory()) {
if (false == ftpFile.isDirectory()) {
// 本地不存在文件或者ftp上文件有修改则下载
if (!FileUtil.exist(destFile)
if (false == FileUtil.exist(destFile)
|| (ftpFile.getTimestamp().getTimeInMillis() > destFile.lastModified())) {
download(srcFile, destFile);
}
Expand All @@ -677,7 +677,7 @@ public void download(String path, String fileName, File outFile) throws IORuntim
if (outFile.isDirectory()) {
outFile = new File(outFile, fileName);
}
if (!outFile.exists()) {
if (false == outFile.exists()) {
FileUtil.touch(outFile);
}
try (OutputStream out = FileUtil.getOutputStream(outFile)) {
Expand Down Expand Up @@ -714,7 +714,7 @@ public void download(String path, String fileName, OutputStream out, Charset fil
pwd = pwd();
}

if (!cd(path)) {
if (false == cd(path)) {
throw new FtpException("Change dir to [{}] error, maybe dir not exist!", path);
}

Expand Down

0 comments on commit 8bbe6bb

Please sign in to comment.