feat: 完善知识库批量导入与公共 API
- 新增批量异步导入、状态查询、失败重试与中断恢复链路 - 拆分知识库读取、导入、维护权限并完善 Public API 契约 - 补充数据库迁移、管理端交互、接口说明与相关测试
This commit is contained in:
@@ -108,7 +108,7 @@ public class LocalFileStorageServiceImpl implements FileStorageService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除旧版路径对应的本地文件。
|
||||
* 幂等删除旧版路径对应的本地文件。
|
||||
*
|
||||
* @param path 文件路径
|
||||
*/
|
||||
@@ -116,7 +116,7 @@ public class LocalFileStorageServiceImpl implements FileStorageService {
|
||||
public void delete(String path) {
|
||||
try {
|
||||
File file = getLocalFile(path);
|
||||
Files.delete(file.toPath());
|
||||
Files.deleteIfExists(file.toPath());
|
||||
} catch (IOException e) {
|
||||
LOG.error("删除本地文件出错: {}", path, e);
|
||||
throw new RuntimeException("删除本地文件出错:",e);
|
||||
|
||||
@@ -80,6 +80,22 @@ public class LocalFileStorageServiceImplTest {
|
||||
assertFalse(Files.exists(part));
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证旧版路径删除在文件已不存在时仍可幂等成功。
|
||||
*
|
||||
* @throws Exception 测试目录或反射配置失败
|
||||
*/
|
||||
@Test
|
||||
public void deleteMissingLegacyPathIsIdempotent() throws Exception {
|
||||
File root = temporaryFolder.newFolder("legacy-delete-root");
|
||||
LocalFileStorageServiceImpl service = createService(root, "/files");
|
||||
|
||||
service.delete("/files/missing.bin");
|
||||
service.delete("/files/missing.bin");
|
||||
|
||||
assertFalse(Files.exists(root.toPath().resolve("missing.bin")));
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证句柄路径中的符号链接不会被跟随到存储根目录外。
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user