4040from open_webui .utils .access_control .files import has_access_to_file
4141from open_webui .models .knowledge import Knowledges
4242from open_webui .storage .provider import Storage
43- from open_webui .internal .db import get_async_session , get_db
43+ from open_webui .internal .db import get_async_db , get_async_session
4444from sqlalchemy .ext .asyncio import AsyncSession
4545
4646
@@ -1694,10 +1694,10 @@ async def process_file(
16941694 try :
16951695 # Commit any pending changes before the slow embedding step.
16961696 # Note: file is already a Pydantic model (not ORM), so no expunge needed.
1697- db .commit ()
1697+ await db .commit ()
16981698
16991699 # External embedding API takes time (5-60s+).
1700- # Subsequent updates use fresh sessions via get_db() .
1700+ # Subsequent updates use fresh async sessions .
17011701 result = save_docs_to_vector_db (
17021702 request ,
17031703 docs = docs ,
@@ -1714,7 +1714,7 @@ async def process_file(
17141714
17151715 if result :
17161716 # Fresh session for the final update.
1717- with get_db () as session :
1717+ async with get_async_db () as session :
17181718 await Files .update_file_metadata_by_id (
17191719 file .id ,
17201720 {
@@ -1744,7 +1744,7 @@ async def process_file(
17441744 except Exception as e :
17451745 log .exception (e )
17461746 # Fresh session for error status update.
1747- with get_db () as session :
1747+ async with get_async_db () as session :
17481748 await Files .update_file_data_by_id (
17491749 file .id ,
17501750 {'status' : 'failed' },
0 commit comments