refac: keep external connections until their last knowledge base is removed (#28113)
Deleting an external knowledge base now clears its connection only when an admin removes the last knowledge base referencing it, matching the connection delete route.
This commit is contained in:
1 parent
6b438f1a79
commit
dc03e7e595
1 file changed
+6
-1
@@ -1733,7 +1733,12 @@ async def delete_knowledge_by_id(
|
|||||||
# Clean up vector DB
|
# Clean up vector DB
|
||||||
if is_external_knowledge(knowledge):
|
if is_external_knowledge(knowledge):
|
||||||
connection_id = (knowledge.meta or {}).get('external', {}).get('connection_id')
|
connection_id = (knowledge.meta or {}).get('external', {}).get('connection_id')
|
||||||
if connection_id:
|
# Connections are admin-owned and shared across knowledge bases
|
||||||
|
if (
|
||||||
|
connection_id
|
||||||
|
and user.role == 'admin'
|
||||||
|
and await _count_external_connection_mappings(connection_id, db=db) <= 1
|
||||||
|
):
|
||||||
connections = [
|
connections = [
|
||||||
connection for connection in await _get_external_connections() if connection.get('id') != connection_id
|
connection for connection in await _get_external_connections() if connection.get('id') != connection_id
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in new issue
Block a user