mirror of
https://github.com/open-webui/open-webui
synced 2024-11-22 08:07:55 +00:00
fix: delete
This commit is contained in:
parent
0d70d7c9ac
commit
c9b85bd4a2
@ -195,6 +195,7 @@ class AuthsTable:
|
||||
|
||||
if result:
|
||||
db.query(Auth).filter_by(id=id).delete()
|
||||
db.commit()
|
||||
|
||||
return True
|
||||
else:
|
||||
|
@ -171,6 +171,8 @@ class ChatTable:
|
||||
with get_db() as db:
|
||||
|
||||
db.query(Chat).filter_by(user_id=f"shared-{chat_id}").delete()
|
||||
db.commit()
|
||||
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
@ -323,6 +325,7 @@ class ChatTable:
|
||||
with get_db() as db:
|
||||
|
||||
db.query(Chat).filter_by(id=id).delete()
|
||||
db.commit()
|
||||
|
||||
return True and self.delete_shared_chat_by_chat_id(id)
|
||||
except:
|
||||
@ -333,6 +336,7 @@ class ChatTable:
|
||||
with get_db() as db:
|
||||
|
||||
db.query(Chat).filter_by(id=id, user_id=user_id).delete()
|
||||
db.commit()
|
||||
|
||||
return True and self.delete_shared_chat_by_chat_id(id)
|
||||
except:
|
||||
@ -346,6 +350,8 @@ class ChatTable:
|
||||
self.delete_shared_chats_by_user_id(user_id)
|
||||
|
||||
db.query(Chat).filter_by(user_id=user_id).delete()
|
||||
db.commit()
|
||||
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
@ -359,6 +365,7 @@ class ChatTable:
|
||||
shared_chat_ids = [f"shared-{chat.id}" for chat in chats_by_user]
|
||||
|
||||
db.query(Chat).filter(Chat.user_id.in_(shared_chat_ids)).delete()
|
||||
db.commit()
|
||||
|
||||
return True
|
||||
except:
|
||||
|
@ -104,6 +104,8 @@ class FilesTable:
|
||||
|
||||
try:
|
||||
db.query(File).filter_by(id=id).delete()
|
||||
db.commit()
|
||||
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
@ -114,6 +116,8 @@ class FilesTable:
|
||||
|
||||
try:
|
||||
db.query(File).delete()
|
||||
db.commit()
|
||||
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
@ -267,9 +267,10 @@ class FunctionsTable:
|
||||
|
||||
def delete_function_by_id(self, id: str) -> bool:
|
||||
with get_db() as db:
|
||||
|
||||
try:
|
||||
db.query(Function).filter_by(id=id).delete()
|
||||
db.commit()
|
||||
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
@ -115,6 +115,8 @@ class MemoriesTable:
|
||||
|
||||
try:
|
||||
db.query(Memory).filter_by(id=id).delete()
|
||||
db.commit()
|
||||
|
||||
return True
|
||||
|
||||
except:
|
||||
@ -125,6 +127,8 @@ class MemoriesTable:
|
||||
|
||||
try:
|
||||
db.query(Memory).filter_by(user_id=user_id).delete()
|
||||
db.commit()
|
||||
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
@ -134,6 +138,8 @@ class MemoriesTable:
|
||||
|
||||
try:
|
||||
db.query(Memory).filter_by(id=id, user_id=user_id).delete()
|
||||
db.commit()
|
||||
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
@ -176,6 +176,8 @@ class ModelsTable:
|
||||
with get_db() as db:
|
||||
|
||||
db.query(Model).filter_by(id=id).delete()
|
||||
db.commit()
|
||||
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
@ -109,6 +109,8 @@ class PromptsTable:
|
||||
with get_db() as db:
|
||||
|
||||
db.query(Prompt).filter_by(command=command).delete()
|
||||
db.commit()
|
||||
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
@ -225,6 +225,7 @@ class TagTable:
|
||||
if tag_count == 0:
|
||||
# Remove tag item from Tag col as well
|
||||
db.query(Tag).filter_by(name=tag_name, user_id=user_id).delete()
|
||||
db.commit()
|
||||
return True
|
||||
except Exception as e:
|
||||
log.error(f"delete_tag: {e}")
|
||||
@ -250,6 +251,7 @@ class TagTable:
|
||||
if tag_count == 0:
|
||||
# Remove tag item from Tag col as well
|
||||
db.query(Tag).filter_by(name=tag_name, user_id=user_id).delete()
|
||||
db.commit()
|
||||
|
||||
return True
|
||||
except Exception as e:
|
||||
|
@ -201,6 +201,8 @@ class ToolsTable:
|
||||
try:
|
||||
with get_db() as db:
|
||||
db.query(Tool).filter_by(id=id).delete()
|
||||
db.commit()
|
||||
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
@ -233,7 +233,10 @@ async def delete_function_by_id(
|
||||
|
||||
# delete the function file
|
||||
function_path = os.path.join(FUNCTIONS_DIR, f"{id}.py")
|
||||
os.remove(function_path)
|
||||
try:
|
||||
os.remove(function_path)
|
||||
except:
|
||||
pass
|
||||
|
||||
return result
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user