open-webui/backend/open_webui/models
Classic298 4f98a5184f
perf: resolve model-attached file access with a targeted query (#28802)
Checking whether a user may reach a file loaded and validated every workspace model that user can access, then scanned each model's knowledge list in Python for one file id. Folder listings run that check once per file, so opening a folder of twenty files rebuilt the whole accessible-model set twenty times, and the same check sits on every retrieval and download path.

The lookup now runs the other way round: the database returns the models that attach the file, and only those are access-checked. The text match on the metadata column is a prefilter and the knowledge entries still decide, so a file id that merely appears in a description grants nothing; file ids are server-generated uuids, so the match can only be too wide, never too narrow.

Measured with 500 accessible workspace models: a single check drops from 9 queries and ~20 ms to 6 and ~2.6 ms, and a twenty-file folder listing from 180 queries and ~680 ms to 120 and ~56 ms. A 72-case matrix over owner, public, direct-user and group grants, for both read and write, returns exactly what it returned before, and write still requires the model owner to own the file. The check also no longer writes to the database while answering a read-only question.
2026-08-19 11:07:43 -07:00
..
access_grants.py fix: list publicly shared read-only notes in the Read Only view (#27637) 2026-08-17 01:40:56 -06:00
auths.py refac 2026-07-27 04:50:07 -04:00
automations.py fix: match both JSON text spellings when searching serialised JSON columns (#28399) 2026-08-17 01:24:05 -06:00
calendar.py refac 2026-07-27 02:44:21 -04:00
channels.py refac 2026-08-10 20:00:43 -06:00
chat_messages.py perf: write a chat's messages in one transaction instead of one per message (#28806) 2026-08-19 12:46:49 -05:00
chats.py perf: write a chat's messages in one transaction instead of one per message (#28806) 2026-08-19 12:46:49 -05:00
config.py refac 2026-08-13 15:02:18 -06:00
feedbacks.py perf: drop redundant session.refresh calls after commit across the model layer (#27381) 2026-07-23 18:08:00 -05:00
files.py perf: drop redundant session.refresh calls after commit across the model layer (#27381) 2026-07-23 18:08:00 -05:00
folders.py perf: batch the shared folder listing instead of fetching one folder at a time (#28804) 2026-08-19 11:06:37 -07:00
functions.py fix: prevent startup crash when function/tool has null user_id (#26850) 2026-07-24 00:00:37 -05:00
groups.py perf: index group_member on (user_id, group_id) (#27822) 2026-07-31 19:09:15 -05:00
knowledge.py refac: remove unused knowledge base accessors (#28794) 2026-08-19 11:07:21 -07:00
memories.py refac 2026-07-24 01:54:36 -04:00
messages.py chore: remove dead json imports (#27815) 2026-07-31 17:25:40 -04:00
models.py perf: resolve model-attached file access with a targeted query (#28802) 2026-08-19 11:07:43 -07:00
notes.py refac 2026-08-10 19:46:46 -06:00
oauth_sessions.py refac 2026-07-31 17:41:14 -04:00
prompt_history.py chore: remove dead json imports (#27815) 2026-07-31 17:25:40 -04:00
prompts.py fix: match both JSON text spellings when searching serialised JSON columns (#28399) 2026-08-17 01:24:05 -06:00
shared_chats.py feat(ui): add 'Unshare All Shared Chats' button to Shared Chats modal (#25848) 2026-06-17 03:06:41 +02:00
skills.py perf: stop scanning every skill on each listing and chat turn (#28798) 2026-08-19 11:07:33 -07:00
tags.py perf: build debug log messages lazily so disabled debug logs cost nothing (#27834) 2026-07-31 19:09:01 -05:00
tools.py refac 2026-07-27 02:44:21 -04:00
users.py refactor: match provider identity lookups via JSON subscript (#28624) 2026-08-17 01:05:16 -06:00