🔨 优化 sftp 代码逻辑.

This commit is contained in:
lijiahang
2024-02-19 17:32:20 +08:00
parent 104090887e
commit 4117fb3ffa
15 changed files with 163 additions and 54 deletions

View File

@@ -77,4 +77,6 @@ public interface ErrorMessage {
String CONNECT_ERROR = "连接失败";
String PATH_NOT_NORMALIZE = "路径不合法";
}

View File

@@ -1,6 +1,7 @@
package com.orion.ops.framework.common.utils;
import com.orion.lang.utils.Arrays1;
import com.orion.lang.utils.io.Files1;
import com.orion.ops.framework.common.constant.ErrorMessage;
import com.orion.spring.SpringHolder;
@@ -116,4 +117,15 @@ public class Valid extends com.orion.lang.utils.Valid {
return effect;
}
/**
* 检查路径是否合法化 即不包含 ./ ../
*
* @param path path
*/
public static String checkNormalize(String path) {
Valid.notBlank(path);
Valid.isTrue(Files1.isNormalize(path), ErrorMessage.PATH_NOT_NORMALIZE);
return Files1.getPath(path);
}
}