Rewrite logic

This commit is contained in:
Juan Calderon-Perez 2025-04-08 00:56:21 -04:00 committed by GitHub
parent 8609ca3657
commit 1c60b8d543
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 = [