mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-23 04:40:15 +08:00
Fix commonpath / using arg.cwd on Windows
This commit is contained in:
parent
8508a5a853
commit
04ce040d28
@ -2,6 +2,8 @@ import json
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import uuid
|
import uuid
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
from ..cli_args import args
|
from ..cli_args import args
|
||||||
from ..cmd.folder_paths import user_directory
|
from ..cmd.folder_paths import user_directory
|
||||||
@ -50,7 +52,7 @@ class UserManager():
|
|||||||
|
|
||||||
# prevent leaving /{type}
|
# prevent leaving /{type}
|
||||||
if os.path.commonpath((root_dir, user_root)) != root_dir:
|
if os.path.commonpath((root_dir, user_root)) != root_dir:
|
||||||
return None
|
raise PermissionError()
|
||||||
|
|
||||||
parent = user_root
|
parent = user_root
|
||||||
|
|
||||||
@ -58,7 +60,7 @@ class UserManager():
|
|||||||
# prevent leaving /{type}/{user}
|
# prevent leaving /{type}/{user}
|
||||||
path = os.path.abspath(os.path.join(user_root, file))
|
path = os.path.abspath(os.path.join(user_root, file))
|
||||||
if os.path.commonpath((user_root, path)) != user_root:
|
if os.path.commonpath((user_root, path)) != user_root:
|
||||||
return None
|
raise PermissionError()
|
||||||
|
|
||||||
if create_dir and not os.path.exists(parent):
|
if create_dir and not os.path.exists(parent):
|
||||||
os.mkdir(parent)
|
os.mkdir(parent)
|
||||||
|
|||||||
@ -45,7 +45,7 @@ class EmbeddedComfyClient:
|
|||||||
async with EmbeddedComfyClient() as client:
|
async with EmbeddedComfyClient() as client:
|
||||||
outputs = await client.queue_prompt(prompt)
|
outputs = await client.queue_prompt(prompt)
|
||||||
|
|
||||||
print(result)
|
print(outputs)
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
@ -11,13 +11,14 @@ folder_names_and_paths = {}
|
|||||||
|
|
||||||
if 'main.py' in sys.argv:
|
if 'main.py' in sys.argv:
|
||||||
base_path = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../.."))
|
base_path = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../.."))
|
||||||
elif args.cwd:
|
elif args.cwd is not None:
|
||||||
if not os.path.exists(args.cwd):
|
if not os.path.exists(args.cwd):
|
||||||
try:
|
try:
|
||||||
os.makedirs(args.cwd)
|
os.makedirs(args.cwd, exist_ok=True)
|
||||||
except:
|
except:
|
||||||
print("Failed to create custom working directory")
|
print("Failed to create custom working directory")
|
||||||
base_path = args.cwd
|
# wrap the path to prevent slashedness from glitching out common path checks
|
||||||
|
base_path = os.path.realpath(args.cwd)
|
||||||
else:
|
else:
|
||||||
base_path = os.getcwd()
|
base_path = os.getcwd()
|
||||||
models_dir = os.path.join(base_path, "models")
|
models_dir = os.path.join(base_path, "models")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user