fix: 修复codex review发现的问题

问题1 - 行锁持有时间过长:
- 采用双重检查锁定模式,将HTTP调用移到锁范围外
- 新增 _update_knowledge_set_config 方法专门处理加锁更新

问题2 - 清理不完整:
- _list_knowledge_sets 方法添加分页参数
- 新增 _list_all_knowledge_sets 方法遍历所有知识集
- 清理方法使用新的全量查询方法

问题3 - 文件删除逻辑可能误删:
- deleteKnowledgeItemFile 方法增加严格的 sourceType 检查
- 只有当 sourceType 为 FILE_UPLOAD 或 MANUAL 时才删除文件
- 避免误删 DATASET_FILE 类型的数据集文件

涉及文件:
- knowledge_sync.py
- KnowledgeItemApplicationService.java
This commit is contained in:
2026-02-05 04:07:40 +08:00
parent 99bd83d312
commit 4143bc75f9
2 changed files with 81 additions and 48 deletions

View File

@@ -809,8 +809,8 @@ public class KnowledgeItemApplicationService {
if (knowledgeItem == null) {
return;
}
if (knowledgeItem.getSourceType() == KnowledgeSourceType.FILE_UPLOAD
|| knowledgeItem.getContentType() == KnowledgeContentType.FILE) {
KnowledgeSourceType sourceType = knowledgeItem.getSourceType();
if (sourceType == KnowledgeSourceType.FILE_UPLOAD || sourceType == KnowledgeSourceType.MANUAL) {
String relativePath = knowledgeItem.getContent();
if (StringUtils.isNotBlank(relativePath)) {
try {