aboutsummaryrefslogtreecommitdiff
path: root/modules/ui_tempdir.py
diff options
context:
space:
mode:
Diffstat (limited to 'modules/ui_tempdir.py')
-rw-r--r--modules/ui_tempdir.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/modules/ui_tempdir.py b/modules/ui_tempdir.py
index 91f40ea4..621ed1ec 100644
--- a/modules/ui_tempdir.py
+++ b/modules/ui_tempdir.py
@@ -81,3 +81,18 @@ def cleanup_tmpdr():
filename = os.path.join(root, name)
os.remove(filename)
+
+
+def is_gradio_temp_path(path):
+ """
+ Check if the path is a temp dir used by gradio
+ """
+ path = Path(path)
+ if shared.opts.temp_dir and path.is_relative_to(shared.opts.temp_dir):
+ return True
+ if gradio_temp_dir := os.environ.get("GRADIO_TEMP_DIR"):
+ if path.is_relative_to(gradio_temp_dir):
+ return True
+ if path.is_relative_to(Path(tempfile.gettempdir()) / "gradio"):
+ return True
+ return False