瀏覽代碼

Rewrite logic

Juan Calderon-Perez 6 月之前
父節點
當前提交
1c60b8d543
共有 1 個文件被更改,包括 8 次插入16 次删除
  1. 8 16
      backend/open_webui/routers/files.py

+ 8 - 16
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 = [