WIP: Optimize /file route (#7416)

* Improve File route

* file route fix

* add changeset

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
Freddy Boulton 2024-02-15 13:50:13 -08:00 committed by GitHub
parent a6371bbcae
commit c88290d90a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
"gradio": patch
---
feat:WIP: Optimize /file route

View File

@ -439,7 +439,11 @@ class App(FastAPI):
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