From 1c60b8d543d37fc56c71b2a7debaf3d9dda76570 Mon Sep 17 00:00:00 2001 From: Juan Calderon-Perez <835733+gaby@users.noreply.github.com> Date: Tue, 8 Apr 2025 00:56:21 -0400 Subject: [PATCH] Rewrite logic --- backend/open_webui/routers/files.py | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/backend/open_webui/routers/files.py b/backend/open_webui/routers/files.py index e1113473d..61ee89f43 100644 --- a/backend/open_webui/routers/files.py +++ b/backend/open_webui/routers/files.py @@ -2,7 +2,6 @@ import logging import os import uuid from fnmatch import fnmatch -from functools import lru_cache from pathlib import Path from typing import Optional from urllib.parse import quote @@ -74,19 +73,6 @@ def has_access_to_file( return has_access -############################ -# Get all files for user, with 1 cache -############################ - - -@lru_cache(maxsize=1) -def get_all_files_for_user(user_id: str, admin: bool): - if admin: - return Files.get_files() - else: - return Files.get_files_by_user_id(user_id) - - ############################ # Upload File ############################ @@ -205,8 +191,14 @@ async def search_files( ), user=Depends(get_verified_user), ): - # Retrieve files from cache - files = get_all_files_for_user(user.id, user.role == "admin") + """ + Search for files by filename with support for wildcard patterns. + """ + # Get files according to user role + if user.role == "admin": + files = Files.get_files() + else: + files = Files.get_files_by_user_id(user.id) # Get matching files matching_files = [