mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-12 07:10:52 +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 re
|
||||
import uuid
|
||||
from typing import Optional
|
||||
|
||||
from aiohttp import web
|
||||
from ..cli_args import args
|
||||
from ..cmd.folder_paths import user_directory
|
||||
@ -50,7 +52,7 @@ class UserManager():
|
||||
|
||||
# prevent leaving /{type}
|
||||
if os.path.commonpath((root_dir, user_root)) != root_dir:
|
||||
return None
|
||||
raise PermissionError()
|
||||
|
||||
parent = user_root
|
||||
|
||||
@ -58,7 +60,7 @@ class UserManager():
|
||||
# prevent leaving /{type}/{user}
|
||||
path = os.path.abspath(os.path.join(user_root, file))
|
||||
if os.path.commonpath((user_root, path)) != user_root:
|
||||
return None
|
||||
raise PermissionError()
|
||||
|
||||
if create_dir and not os.path.exists(parent):
|
||||
os.mkdir(parent)
|
||||
|
||||
@ -45,7 +45,7 @@ class EmbeddedComfyClient:
|
||||
async with EmbeddedComfyClient() as client:
|
||||
outputs = await client.queue_prompt(prompt)
|
||||
|
||||
print(result)
|
||||
print(outputs)
|
||||
```
|
||||
"""
|
||||
|
||||
|
||||
@ -11,13 +11,14 @@ folder_names_and_paths = {}
|
||||
|
||||
if 'main.py' in sys.argv:
|
||||
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):
|
||||
try:
|
||||
os.makedirs(args.cwd)
|
||||
os.makedirs(args.cwd, exist_ok=True)
|
||||
except:
|
||||
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:
|
||||
base_path = os.getcwd()
|
||||
models_dir = os.path.join(base_path, "models")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user