Address Docker regression: detect container mode for aria2 path remapping

In Docker, aria2 runs in a separate container with only mounted paths
visible (e.g. /models, /custom_nodes), not host absolute paths. Detect
Docker via /.dockerenv or COMFYUI_ARIA2_CONTAINER_PATHS=true env var and
remap to container-relative paths in that case. On bare-metal, use the
full absolute path so aria2 can locate the directory.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ViolinKaine 2026-06-15 20:51:51 +02:00
parent 857b4534f1
commit 0681955bd8

View File

@ -80,7 +80,15 @@ def aria2_download_url(model_url: str, model_dir: str, filename: str):
import tqdm import tqdm
import time import time
if os.path.isabs(model_dir): # In Docker, aria2 runs in a separate container and can only access
# container-relative mount paths (e.g. /models, /custom_nodes), not host
# absolute paths. Outside Docker, use the full absolute path directly.
in_docker = os.path.exists('/.dockerenv') or os.environ.get('COMFYUI_ARIA2_CONTAINER_PATHS', '').lower() == 'true'
if in_docker and model_dir.startswith(core.comfy_path):
rel = model_dir[len(core.comfy_path):]
download_dir = rel if rel.startswith('/') else '/' + rel
elif os.path.isabs(model_dir):
download_dir = model_dir download_dir = model_dir
else: else:
download_dir = os.path.join('/models', model_dir) download_dir = os.path.join('/models', model_dir)