mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 23:23:55 +08:00
#3212 fix:
1.修复RAGFlow连接异常导致级联删除问题 2.修复RAGFlow获取数量逻辑问题 3.远程失败不再删除本地影子记录,避免产生RAGFlow端孤儿文档 4.优化前端提示语
This commit is contained in:
+5
-10
@@ -485,16 +485,11 @@ public class RAGFlowAdapter extends KnowledgeBaseAdapter {
|
||||
|
||||
@Override
|
||||
public Integer getDocumentCount(String datasetId) {
|
||||
try {
|
||||
DatasetDTO.InfoVO info = getDatasetInfo(datasetId);
|
||||
if (info != null && info.getDocumentCount() != null) {
|
||||
return info.getDocumentCount().intValue();
|
||||
}
|
||||
return 0;
|
||||
} catch (Exception e) {
|
||||
log.warn("获取文档数量失败: {}", e.getMessage());
|
||||
return 0;
|
||||
DatasetDTO.InfoVO info = getDatasetInfo(datasetId);
|
||||
if (info != null && info.getDocumentCount() != null) {
|
||||
return info.getDocumentCount().intValue();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -518,7 +513,7 @@ public class RAGFlowAdapter extends KnowledgeBaseAdapter {
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
log.warn("获取数据集信息失败: datasetId={}, error={}", datasetId, e.getMessage());
|
||||
return null;
|
||||
throw convertToRenException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -100,9 +100,9 @@ public class KnowledgeBaseServiceImpl extends BaseServiceImpl<KnowledgeBaseDao,
|
||||
}
|
||||
|
||||
DatasetDTO.InfoVO datasetInfo = adapter.getDatasetInfo(dto.getDatasetId());
|
||||
|
||||
// getDatasetInfo 正常返回 null 表示远端确实不存在;异常时已抛出 RenException 由外层 catch 接管
|
||||
if (datasetInfo == null) {
|
||||
// RAGFlow 端已删除 → 本地级联清理
|
||||
// RAGFlow 端已确认删除 → 本地级联清理
|
||||
log.info("数据集 {} 在 RAGFlow 端不存在,执行本地清理", dto.getDatasetId());
|
||||
cleanupLocalDataset(dto.getDatasetId(), dto.getId());
|
||||
// 标记为已删除,让上层从列表中移除
|
||||
|
||||
+2
-1
@@ -529,7 +529,8 @@ public class KnowledgeFilesServiceImpl extends BaseServiceImpl<DocumentDao, Docu
|
||||
adapter.deleteDocument(datasetId, req);
|
||||
log.info("远程批量删除请求成功");
|
||||
} catch (Exception e) {
|
||||
log.warn("远程删除请求部分或全部失败: {}", e.getMessage());
|
||||
log.error("远程删除请求失败,中止本地清理以避免数据不一致: {}", e.getMessage());
|
||||
throw new RenException(e.getMessage());
|
||||
}
|
||||
|
||||
// 4. 原子化清理本地影子记录并同步统计数据
|
||||
|
||||
Reference in New Issue
Block a user