mirror of
https://github.com/HuangYuChuh/ComfyUI_Skills_OpenClaw.git
synced 2026-07-30 19:49:07 +00:00
Motivation: To prevent path traversal via server/workflow identifiers and ensure relative path consistency for output directories across different server environments. Implementation: - Added is_valid_identifier validation to comfyui_client and server_manager. - Standardized default output_dir to relative './outputs' in config and settings.
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent.parent
|
|
CONFIG_PATH = BASE_DIR / "config.json"
|
|
DATA_DIR = BASE_DIR / "data"
|
|
OUTPUTS_DIR = BASE_DIR / "outputs"
|
|
DEFAULT_COMFYUI_SERVER_URL = "http://127.0.0.1:8188"
|
|
DEFAULT_SERVER_ID = "local"
|
|
DEFAULT_OUTPUT_DIR = "./outputs"
|
|
|
|
|
|
def default_server() -> dict[str, object]:
|
|
return {
|
|
"id": DEFAULT_SERVER_ID,
|
|
"name": "Local",
|
|
"url": DEFAULT_COMFYUI_SERVER_URL,
|
|
"enabled": True,
|
|
"output_dir": DEFAULT_OUTPUT_DIR,
|
|
}
|
|
|
|
|
|
def default_config() -> dict[str, object]:
|
|
return {
|
|
"servers": [default_server()],
|
|
"default_server": DEFAULT_SERVER_ID,
|
|
}
|
|
|
|
|
|
def get_server_data_dir(server_id: str) -> Path:
|
|
"""Return the data directory for a specific server."""
|
|
return DATA_DIR / server_id
|
|
|
|
|
|
def get_server_workflows_dir(server_id: str) -> Path:
|
|
return get_server_data_dir(server_id) / "workflows"
|
|
|
|
|
|
def get_server_schemas_dir(server_id: str) -> Path:
|
|
return get_server_data_dir(server_id) / "schemas"
|