⬆️ 升级 orion kit 版本.
This commit is contained in:
@@ -34,9 +34,6 @@ public class CommandSnippetCacheDTO implements LongCacheIdModel, Serializable {
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "触发前缀")
|
||||
private String prefix;
|
||||
|
||||
@Schema(description = "代码片段")
|
||||
private String command;
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.orion.visor.module.asset.entity.dto;
|
||||
|
||||
import com.orion.visor.framework.desensitize.core.annotation.DesensitizeObject;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 主机终端传输参数
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/12/26 15:47
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@DesensitizeObject
|
||||
@Schema(name = "HostTerminalTransferDTO", description = "主机终端传输参数")
|
||||
public class HostTerminalTransferDTO {
|
||||
|
||||
@Schema(description = "userId")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "username")
|
||||
private String username;
|
||||
|
||||
}
|
||||
@@ -33,9 +33,6 @@ public class CommandSnippetVO implements Serializable {
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "触发前缀")
|
||||
private String prefix;
|
||||
|
||||
@Schema(description = "代码片段")
|
||||
private String command;
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.common.utils.Valid;
|
||||
import com.orion.visor.module.asset.handler.host.terminal.model.TerminalConfig;
|
||||
import com.orion.visor.module.asset.handler.host.terminal.model.response.SftpFileVO;
|
||||
import com.orion.visor.module.asset.utils.SftpUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
|
||||
@@ -84,9 +83,7 @@ public class SftpSession extends TerminalSession implements ISftpSession {
|
||||
public void move(String source, String target) {
|
||||
source = Valid.checkNormalize(source);
|
||||
// 移动
|
||||
SftpUtils.move(executor, source, target);
|
||||
// FIXME kit
|
||||
// executor.move(source, target);
|
||||
executor.move(source, target);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,9 +2,7 @@ package com.orion.visor.module.asset.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.orion.lang.utils.Booleans;
|
||||
import com.orion.lang.utils.Exceptions;
|
||||
import com.orion.lang.utils.Strings;
|
||||
import com.orion.lang.utils.io.Files1;
|
||||
import com.orion.net.host.sftp.SftpExecutor;
|
||||
import com.orion.net.host.sftp.SftpFile;
|
||||
import com.orion.visor.module.asset.define.config.AppSftpConfig;
|
||||
@@ -41,49 +39,8 @@ public class SftpUtils {
|
||||
SftpFileBackupParams backupParams = new SftpFileBackupParams(file.getName(), System.currentTimeMillis());
|
||||
String target = Strings.format(config.getBackupFileName(), JSON.parseObject(JSON.toJSONString(backupParams)));
|
||||
// 移动
|
||||
// FIXME kit
|
||||
move(executor, path, target);
|
||||
// executor.move(path, target);
|
||||
executor.move(path, target);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动文件
|
||||
* FIXME kit DELETE
|
||||
*
|
||||
* @param executor executor
|
||||
* @param source source
|
||||
* @param target target
|
||||
*/
|
||||
public static void move(SftpExecutor executor, String source, String target) {
|
||||
try {
|
||||
source = Files1.getPath(source);
|
||||
target = Files1.getPath(target);
|
||||
if (target.charAt(0) == '/') {
|
||||
// 检查是否需要创建目标文件目录
|
||||
if (!isSameParentPath(source, target)) {
|
||||
executor.makeDirectories(Files1.getParentPath(target));
|
||||
}
|
||||
// 绝对路径
|
||||
executor.getChannel().rename(source, Files1.getPath(Files1.normalize(target)));
|
||||
} else {
|
||||
// 相对路径
|
||||
executor.getChannel().rename(source, Files1.getPath(Files1.normalize(Files1.getPath(source + "/../" + target))));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw Exceptions.sftp(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME kit DELETE
|
||||
*
|
||||
* @param source source
|
||||
* @param target target
|
||||
* @return res
|
||||
*/
|
||||
private static boolean isSameParentPath(String source, String target) {
|
||||
return Files1.getParentPath(source).equals(Files1.getParentPath(target));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user