Skip to content

Commit 914ccf0

Browse files
committed
refac
1 parent ba83613 commit 914ccf0

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

backend/open_webui/routers/knowledge.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,11 @@ async def remove_file_from_knowledge_by_id(
826826
log.debug(e)
827827
pass
828828

829-
if delete_file:
829+
# Only the file owner or an admin may permanently delete the underlying
830+
# file. Collaborators with KB write access can unlink a file from the
831+
# knowledge base but must not be able to destroy files they do not own,
832+
# as the same file may be referenced by other KBs and chats.
833+
if delete_file and (file.user_id == user.id or user.role == 'admin'):
830834
try:
831835
# Remove the file's collection from vector database
832836
file_collection = f'file-{form_data.file_id}'

0 commit comments

Comments
 (0)