From cd86ea63212f713715f1f3401b4c2c7449ef4dce Mon Sep 17 00:00:00 2001 From: CalamitousFelicitousness Date: Sun, 13 Sep 2026 05:09:03 +0100 Subject: [PATCH] fix(civitai): keep windows separators literal in save subfolder paths resolve_save_path passed os.sep as the re.sub replacement string; on Windows that lone backslash is an unfinished escape and every subfolder download raised PatternError. A callable replacement is inserted verbatim. --- modules/civitai/filemanage_civitai.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/civitai/filemanage_civitai.py b/modules/civitai/filemanage_civitai.py index f67229939..b755bbd50 100644 --- a/modules/civitai/filemanage_civitai.py +++ b/modules/civitai/filemanage_civitai.py @@ -118,7 +118,7 @@ def resolve_save_path(model_type: str, model_name: str = "", base_model: str = " for key, value in replacements.items(): subfolder = subfolder.replace(key, value) # Clean up empty path segments - subfolder = re.sub(r'[/\\]+', os.sep, subfolder) + subfolder = re.sub(r'[/\\]+', lambda _match: os.sep, subfolder) # callable repl: a string repl reads the Windows backslash as an escape subfolder = subfolder.strip(os.sep) return base_folder / subfolder