option "open image button" open the actual dir

This commit is contained in:
w-e-w
2024-02-18 00:38:05 +09:00
parent 4ff1fabc86
commit a18e54ecd7
3 changed files with 54 additions and 17 deletions

View File

@@ -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