Skip to content

Commit

Permalink
WIP: Optimize /file route (#7416)
Browse files Browse the repository at this point in the history
* Improve File route

* file route fix

* add changeset

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
freddyaboulton and gradio-pr-bot committed Feb 15, 2024
1 parent a6371bb commit c88290d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/evil-lamps-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gradio": patch
---

feat:WIP: Optimize /file route
6 changes: 5 additions & 1 deletion gradio/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c88290d

Please sign in to comment.