mirror of
https://github.com/open-webui/open-webui.git
synced 2026-06-14 03:30:25 +00:00
refac
This commit is contained in:
@@ -133,12 +133,6 @@ class JSONField(types.TypeDecorator): # TEXT-backed JSON storage
|
||||
return json.loads(value) if value is not None else None
|
||||
def copy(self, **kwargs: Any) -> Self:
|
||||
return JSONField(length=self.impl.length)
|
||||
def db_value(self, value):
|
||||
return json.dumps(value)
|
||||
|
||||
def python_value(self, value):
|
||||
if value is not None:
|
||||
return json.loads(value)
|
||||
|
||||
|
||||
# Normalize SSL params from the URL once; the sync engine needs them
|
||||
|
||||
@@ -96,21 +96,16 @@ async def download_chat_as_pdf(form_data: ChatTitleMessagesForm, user=Depends(ge
|
||||
async def download_db(user=Depends(get_admin_user)):
|
||||
"""Download the raw SQLite database file (admin-only, SQLite deployments only)."""
|
||||
if not ENABLE_ADMIN_EXPORT:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
|
||||
)
|
||||
# --- resolve target database engine ---
|
||||
from open_webui.internal.db import engine # lazy — avoids circular at import time
|
||||
if engine.name != 'sqlite': # non-SQLite backends use pg_dump / managed exports
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=ERROR_MESSAGES.DB_NOT_SQLITE,
|
||||
)
|
||||
raise HTTPException(status.HTTP_401_UNAUTHORIZED, detail=ERROR_MESSAGES.ACCESS_PROHIBITED)
|
||||
|
||||
# Lazy import avoids circular dependency at module load time
|
||||
from open_webui.internal.db import engine
|
||||
|
||||
if engine.name != 'sqlite':
|
||||
raise HTTPException(status.HTTP_400_BAD_REQUEST, detail=ERROR_MESSAGES.DB_NOT_SQLITE)
|
||||
|
||||
return FileResponse(
|
||||
str(engine.url.database),
|
||||
|
||||
media_type='application/octet-stream',
|
||||
filename='webui.db',
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user