Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Optimize /file route #7416

Merged
merged 6 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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