refac
This commit is contained in:
1 parent
d8b5b9fa79
commit
1acfbb6755
2 files changed
+7
-18
No files matched your search
@@ -133,12 +133,6 @@ class JSONField(types.TypeDecorator): # TEXT-backed JSON storage
|
|||||||
return json.loads(value) if value is not None else None
|
return json.loads(value) if value is not None else None
|
||||||
def copy(self, **kwargs: Any) -> Self:
|
def copy(self, **kwargs: Any) -> Self:
|
||||||
return JSONField(length=self.impl.length)
|
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
|
# 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)):
|
async def download_db(user=Depends(get_admin_user)):
|
||||||
"""Download the raw SQLite database file (admin-only, SQLite deployments only)."""
|
"""Download the raw SQLite database file (admin-only, SQLite deployments only)."""
|
||||||
if not ENABLE_ADMIN_EXPORT:
|
if not ENABLE_ADMIN_EXPORT:
|
||||||
raise HTTPException(
|
raise HTTPException(status.HTTP_401_UNAUTHORIZED, detail=ERROR_MESSAGES.ACCESS_PROHIBITED)
|
||||||
status_code=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
|
||||||
# --- resolve target database engine ---
|
|
||||||
from open_webui.internal.db import engine # lazy — avoids circular at import time
|
if engine.name != 'sqlite':
|
||||||
if engine.name != 'sqlite': # non-SQLite backends use pg_dump / managed exports
|
raise HTTPException(status.HTTP_400_BAD_REQUEST, detail=ERROR_MESSAGES.DB_NOT_SQLITE)
|
||||||
raise HTTPException(
|
|
||||||
status_code=status.HTTP_400_BAD_REQUEST,
|
|
||||||
detail=ERROR_MESSAGES.DB_NOT_SQLITE,
|
|
||||||
)
|
|
||||||
|
|
||||||
return FileResponse(
|
return FileResponse(
|
||||||
str(engine.url.database),
|
str(engine.url.database),
|
||||||
|
|
||||||
media_type='application/octet-stream',
|
media_type='application/octet-stream',
|
||||||
filename='webui.db',
|
filename='webui.db',
|
||||||
)
|
)
|
||||||
Reference in new issue
Block a user