fix(dataset): 解决数据集文件查询时空目录导致异常的问题

- 添加目录存在性检查,避免文件系统访问异常
- 目录不存在时返回空分页结果而不是抛出异常
- 优化数据集刚创建时的用户体验
This commit is contained in:
2026-01-31 19:10:22 +08:00
parent 150af1a741
commit 2f3a8b38d0

View File

@@ -170,6 +170,10 @@ public class DatasetFileApplicationService {
.filter(Objects::nonNull)
.collect(Collectors.toSet())
: Collections.emptySet();
// 如果目录不存在,直接返回空结果(数据集刚创建时目录可能还未生成)
if (!Files.exists(queryPath)) {
return new PagedResponse<>(page, size, 0, 0, Collections.emptyList());
}
try (Stream<Path> pathStream = Files.list(queryPath)) {
List<Path> allFiles = pathStream
.filter(path -> path.toString().startsWith(datasetPath))