From 6e4820cad8889acdda408cc875486bf5086d8688 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Thu, 17 Oct 2024 18:42:36 -0700 Subject: [PATCH] refac --- backend/open_webui/apps/webui/models/folders.py | 4 +++- backend/open_webui/apps/webui/routers/folders.py | 5 +---- src/lib/components/layout/Sidebar.svelte | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/backend/open_webui/apps/webui/models/folders.py b/backend/open_webui/apps/webui/models/folders.py index fff7b0e7d..a7b919c8e 100644 --- a/backend/open_webui/apps/webui/models/folders.py +++ b/backend/open_webui/apps/webui/models/folders.py @@ -230,7 +230,9 @@ class FolderTable: user_id, folder_child.id ) delete_children(folder_child) - db.delete(folder_child) + + folder = db.query(Folder).filter_by(id=folder_child.id).first() + db.delete(folder) db.commit() delete_children(folder) diff --git a/backend/open_webui/apps/webui/routers/folders.py b/backend/open_webui/apps/webui/routers/folders.py index c9321fda4..36075c357 100644 --- a/backend/open_webui/apps/webui/routers/folders.py +++ b/backend/open_webui/apps/webui/routers/folders.py @@ -236,10 +236,7 @@ async def delete_folder_by_id(id: str, user=Depends(get_verified_user)): if result: return result else: - raise HTTPException( - status_code=status.HTTP_400_BAD_REQUEST, - detail=ERROR_MESSAGES.DEFAULT("Error deleting folder"), - ) + raise Exception("Error deleting folder") except Exception as e: log.exception(e) log.error(f"Error deleting folder: {id}") diff --git a/src/lib/components/layout/Sidebar.svelte b/src/lib/components/layout/Sidebar.svelte index bb224309a..1eb677f83 100644 --- a/src/lib/components/layout/Sidebar.svelte +++ b/src/lib/components/layout/Sidebar.svelte @@ -1,5 +1,7 @@