liuhua
liuhua
commited on
Commit
·
360c75c
1
Parent(s):
f64944d
Add support for folder deletion (#3635)
Browse files### What problem does this PR solve?
Add support for folder deletion.
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
Co-authored-by: liuhua <[email protected]>
- api/apps/kb_app.py +1 -0
- api/apps/sdk/dataset.py +2 -0
api/apps/kb_app.py
CHANGED
@@ -162,6 +162,7 @@ def rm():
|
|
162 |
message="Database error (Document removal)!")
|
163 |
f2d = File2DocumentService.get_by_document_id(doc.id)
|
164 |
FileService.filter_delete([File.source_type == FileSource.KNOWLEDGEBASE, File.id == f2d[0].file_id])
|
|
|
165 |
File2DocumentService.delete_by_document_id(doc.id)
|
166 |
|
167 |
if not KnowledgebaseService.delete_by_id(req["kb_id"]):
|
|
|
162 |
message="Database error (Document removal)!")
|
163 |
f2d = File2DocumentService.get_by_document_id(doc.id)
|
164 |
FileService.filter_delete([File.source_type == FileSource.KNOWLEDGEBASE, File.id == f2d[0].file_id])
|
165 |
+
FileService.filter_delete([File.source_type == FileSource.KNOWLEDGEBASE, File.type == "folder", File.name == kbs[0].name])
|
166 |
File2DocumentService.delete_by_document_id(doc.id)
|
167 |
|
168 |
if not KnowledgebaseService.delete_by_id(req["kb_id"]):
|
api/apps/sdk/dataset.py
CHANGED
@@ -252,6 +252,8 @@ def delete(tenant_id):
|
|
252 |
File.id == f2d[0].file_id,
|
253 |
]
|
254 |
)
|
|
|
|
|
255 |
File2DocumentService.delete_by_document_id(doc.id)
|
256 |
if not KnowledgebaseService.delete_by_id(id):
|
257 |
return get_error_data_result(message="Delete dataset error.(Database error)")
|
|
|
252 |
File.id == f2d[0].file_id,
|
253 |
]
|
254 |
)
|
255 |
+
FileService.filter_delete(
|
256 |
+
[File.source_type == FileSource.KNOWLEDGEBASE, File.type == "folder", File.name == kbs[0].name])
|
257 |
File2DocumentService.delete_by_document_id(doc.id)
|
258 |
if not KnowledgebaseService.delete_by_id(id):
|
259 |
return get_error_data_result(message="Delete dataset error.(Database error)")
|