diff --git a/api/apps/kb_app.py b/api/apps/kb_app.py index 523d13876..6ab62d824 100644 --- a/api/apps/kb_app.py +++ b/api/apps/kb_app.py @@ -162,6 +162,7 @@ def rm(): message="Database error (Document removal)!") f2d = File2DocumentService.get_by_document_id(doc.id) FileService.filter_delete([File.source_type == FileSource.KNOWLEDGEBASE, File.id == f2d[0].file_id]) + FileService.filter_delete([File.source_type == FileSource.KNOWLEDGEBASE, File.type == "folder", File.name == kbs[0].name]) File2DocumentService.delete_by_document_id(doc.id) if not KnowledgebaseService.delete_by_id(req["kb_id"]): diff --git a/api/apps/sdk/dataset.py b/api/apps/sdk/dataset.py index 61cc3dd84..0dffdf292 100644 --- a/api/apps/sdk/dataset.py +++ b/api/apps/sdk/dataset.py @@ -252,6 +252,8 @@ def delete(tenant_id): File.id == f2d[0].file_id, ] ) + FileService.filter_delete( + [File.source_type == FileSource.KNOWLEDGEBASE, File.type == "folder", File.name == kbs[0].name]) File2DocumentService.delete_by_document_id(doc.id) if not KnowledgebaseService.delete_by_id(id): return get_error_data_result(message="Delete dataset error.(Database error)")