From c88290d90a81811911361e26fa9523c9b13db527 Mon Sep 17 00:00:00 2001 From: Freddy Boulton Date: Thu, 15 Feb 2024 13:50:13 -0800 Subject: [PATCH] WIP: Optimize /file route (#7416) * Improve File route * file route fix * add changeset * add changeset --------- Co-authored-by: gradio-pr-bot --- .changeset/evil-lamps-refuse.md | 5 +++++ gradio/routes.py | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/evil-lamps-refuse.md 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