change changelog

This commit is contained in:
Looly 2021-07-23 09:11:45 +08:00
commit c28156272c
3 changed files with 49 additions and 3 deletions

View File

@ -3,12 +3,13 @@
-------------------------------------------------------------------------------------------------------------
# 5.7.6 (2021-07-19)
# 5.7.6 (2021-07-23)
### 🐣新特性
* 【core 】 增加FieldsComparatorpr#374@Gitee
* 【core 】 FileUtil.del采用Files.delete实现
* 【core 】 改进Base64.isBase64方法增加等号判断issue#1710@Github
* 【core 】 Sftp增加syncUpload方法pr#375@Gitee
* 【core 】 改进NetUtil.getLocalHost逻辑issue#1717@Github
### 🐞Bug修复

View File

@ -1382,8 +1382,23 @@ public class FileUtil extends PathUtil {
* @param file 文件对象
* @param lastModifyTime 上次的改动时间
* @return 是否被改动
* @deprecated 拼写错误请使用{@link #isModified(File, long)}
*/
@Deprecated
public static boolean isModifed(File file, long lastModifyTime) {
return isModified(file,lastModifyTime);
}
/**
* 判断文件是否被改动<br>
* 如果文件对象为 null 或者文件不存在被视为改动
*
* @param file 文件对象
* @param lastModifyTime 上次的改动时间
* @return 是否被改动
*/
public static boolean isModified(File file, long lastModifyTime) {
if (null == file || false == file.exists()) {
return true;
}

View File

@ -319,7 +319,7 @@ public class Sftp extends AbstractFtp {
@Override
public boolean mkdir(String dir) {
if(isDir(dir)){
if (isDir(dir)) {
// 目录已经存在创建直接返回
return true;
}
@ -332,7 +332,7 @@ public class Sftp extends AbstractFtp {
}
@Override
public boolean isDir(String dir){
public boolean isDir(String dir) {
final SftpATTRS sftpATTRS;
try {
sftpATTRS = this.channel.stat(dir);
@ -423,6 +423,36 @@ public class Sftp extends AbstractFtp {
}
}
/**
* 将本地文件或者文件夹同步覆盖上传到远程路径
*
* @param file 文件或者文件夹
* @param remotePath 远程路径
* @since 5.7.6
*/
public void syncUpload(File file, String remotePath) {
if (false == FileUtil.exist(file)) {
return;
}
if (file.isDirectory()) {
File[] files = file.listFiles();
if (files == null) {
return;
}
for (File fileItem : files) {
if (fileItem.isDirectory()) {
String mkdir = FileUtil.normalize(remotePath + "/" + fileItem.getName());
this.syncUpload(fileItem, mkdir);
} else {
this.syncUpload(fileItem, remotePath);
}
}
} else {
this.mkDirs(remotePath);
this.upload(remotePath, file);
}
}
@Override
public boolean upload(String destPath, File file) {
put(FileUtil.getAbsolutePath(file), destPath);