feat: Add JSON parsing for base_model_path_mappings and refactor path handling in DownloadManager

This commit is contained in:
Will Miao
2025-07-21 07:37:34 +08:00
parent 0c883433c1
commit 124002a472
2 changed files with 57 additions and 56 deletions

View File

@@ -1,3 +1,4 @@
import json
import logging
import os
import sys
@@ -179,6 +180,16 @@ class MiscRoutes:
if old_path != value:
logger.info(f"Example images path changed to {value} - server restart required")
# Special handling for base_model_path_mappings - parse JSON string
if key == 'base_model_path_mappings' and value:
try:
value = json.loads(value)
except json.JSONDecodeError:
return web.json_response({
'success': False,
'error': f"Invalid JSON format for base_model_path_mappings: {value}"
})
# Save to settings
settings.set(key, value)