diff --git a/.changeset/evil-lamps-refuse.md b/.changeset/evil-lamps-refuse.md new file mode 100644 index 0000000000000..a345e27815071 --- /dev/null +++ b/.changeset/evil-lamps-refuse.md @@ -0,0 +1,5 @@ +--- +"gradio": patch +--- + +feat:WIP: Optimize /file route diff --git a/gradio/routes.py b/gradio/routes.py index 077c513327439..2ea7fd49a1f6f 100644 --- a/gradio/routes.py +++ b/gradio/routes.py @@ -439,7 +439,11 @@ async def file(path_or_url: str, request: fastapi.Request): if in_blocklist or is_dir: raise HTTPException(403, f"File not allowed: {path_or_url}.") - created_by_app = str(abs_path) in set().union(*blocks.temp_file_sets) + created_by_app = False + for temp_file_set in blocks.temp_file_sets: + if abs_path in temp_file_set: + created_by_app = True + break in_allowlist = any( utils.is_in_or_equal(abs_path, allowed_path) for allowed_path in blocks.allowed_paths