🔨 查询隐藏文件.

This commit is contained in:
lijiahang
2024-02-09 23:57:44 +08:00
parent 3ff67204ab
commit 8f8858fda0
6 changed files with 35 additions and 11 deletions

View File

@@ -28,6 +28,15 @@ public enum BooleanBit {
private final Integer value;
/**
* 是否为布尔值
*
* @return boolean
*/
public boolean booleanValue() {
return this == TRUE;
}
public static BooleanBit of(boolean value) {
return value ? TRUE : FALSE;
}
@@ -44,4 +53,14 @@ public enum BooleanBit {
return null;
}
/**
* 转为布尔值
*
* @param value value
* @return boolean
*/
public static boolean toBoolean(Integer value) {
return TRUE.value.equals(value);
}
}

View File

@@ -46,7 +46,7 @@ public class SftpListHandler extends AbstractTerminalHandler<SftpListRequest> {
path = ((ISftpSession) session).getHome();
}
// 文件列表
list = ((ISftpSession) session).list(path);
list = ((ISftpSession) session).list(path, BooleanBit.toBoolean(payload.getShowHiddenFile()));
} catch (Exception e) {
log.error("SftpListHandler-handle error", e);
ex = e;

View File

@@ -11,7 +11,7 @@ import lombok.experimental.SuperBuilder;
/**
* sftp 修改文件权限 实体对象
* <p>
* i|eff00a1|path|mode
* i|eff00a1|path|mod
*
* @author Jiahang Li
* @version 1.0.0
@@ -22,13 +22,13 @@ import lombok.experimental.SuperBuilder;
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Schema(name = "SftpChangeModeRequest", description = "sftp 修改文件权限 实体对象")
public class SftpChangeModeRequest extends TerminalBasePayload {
@Schema(name = "SftpChangeModRequest", description = "sftp 修改文件权限 实体对象")
public class SftpChangeModRequest extends TerminalBasePayload {
@Schema(description = "path")
private String path;
@Schema(description = "权限")
private String mode;
private String mod;
}

View File

@@ -28,4 +28,7 @@ public class SftpListRequest extends TerminalBasePayload {
@Schema(description = "path")
private String path;
@Schema(description = "是否显示隐藏文件")
private Integer showHiddenFile;
}

View File

@@ -28,9 +28,10 @@ public interface ISftpSession extends ITerminalSession {
/**
* 文件列表
*
* @param path path
* @param path path
* @param showHiddenFile 是否显示隐藏文件
* @return list
*/
List<SftpFileResponse> list(String path);
List<SftpFileResponse> list(String path, boolean showHiddenFile);
}

View File

@@ -1,7 +1,5 @@
package com.orion.ops.module.asset.handler.host.terminal.session;
import com.orion.lang.utils.Strings;
import com.orion.lang.utils.convert.TypeStore;
import com.orion.lang.utils.io.FileType;
import com.orion.lang.utils.io.Files1;
import com.orion.lang.utils.io.Streams;
@@ -56,9 +54,12 @@ public class SftpSession extends TerminalSession implements ISftpSession {
}
@Override
public List<SftpFileResponse> list(String path) {
public List<SftpFileResponse> list(String path, boolean showHiddenFile) {
// 查询文件
List<SftpFile> files = executor.listFilesFilter(path, f -> !f.getName().startsWith("."), false, true);
List<SftpFile> files = executor.listFilesFilter(path,
s -> showHiddenFile || !s.getName().startsWith(Const.DOT),
false,
true);
return files.stream()
.map(SftpSession::fileMapping)
.collect(Collectors.toList());