Files
open-webui/backend
PVBLIC Foundation c3ead772f1 fix: migrate local Gmail/Drive/spend-limit paths to async after v0.9.5
Upstream v0.9.5 made Users.*, OAuthSessions.*, Files.*, and
Knowledges.get_knowledge_by_id async. Local code that wasn't part of the
merge still called these synchronously, which caused both an import-time
crash (knowledge.py used `db: Session = Depends(get_session)` without
importing the symbols) and runtime breakage in Gmail/Drive sync.

Changes:
- routers/knowledge.py: 6 Drive endpoints now use AsyncSession; awaited
  Knowledges.get_knowledge_by_id and has_access calls
- routers/users.py: 6 spend-limit endpoints now use AsyncSession; awaited
  Users.get_user_by_id and Users.update_user_by_id; also awaited the
  force_gmail_sync admin endpoint's Users + OAuthSessions calls
- routers/gmail.py: awaited Users.get_user_by_id (5x),
  Users.update_user_by_id (5x), OAuthSessions
  .get_session_by_provider_and_user_id (3x)
- utils/spend_limit.py: made check_user_spend_limit async; updated
  enforce_spend_limit to await it; awaited Users.get_user_by_id
- utils/gmail_auto_sync.py: awaited Users.get_user_by_id (3x),
  OAuthSessions.get_session_by_provider_and_user_id (2x),
  OAuthSessions.get_sessions_by_user_id
- utils/knowledge_drive_sync.py: awaited Files.insert_new_file,
  Files.get_file_by_id (2x), Files.update_file_data_by_id (2x),
  Users.get_user_by_id

UserUsages.* methods stay sync (they use the local sync get_db_context
fallback restored in 14321d1b3) and continue to work when called with
either sync or async sessions thanks to the isinstance(Session) check.

Made-with: Cursor
2026-05-11 10:54:58 -07:00
..