mirror of
				https://github.com/open-webui/open-webui
				synced 2025-06-26 18:26:48 +00:00 
			
		
		
		
	Rewrite logic
This commit is contained in:
		
							parent
							
								
									8609ca3657
								
							
						
					
					
						commit
						1c60b8d543
					
				@ -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 = [
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user