mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-24 22:52:12 -03:00
refactor: Simplify handling of base model path mappings and download path templates by removing unnecessary JSON.stringify calls
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import json
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@@ -183,16 +182,6 @@ class MiscRoutes:
|
|||||||
if old_path != value:
|
if old_path != value:
|
||||||
logger.info(f"Example images path changed to {value} - server restart required")
|
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' or key == 'download_path_templates') 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
|
# Save to settings
|
||||||
settings.set(key, value)
|
settings.set(key, value)
|
||||||
|
|
||||||
|
|||||||
@@ -132,11 +132,7 @@ export class SettingsManager {
|
|||||||
|
|
||||||
fieldsToSync.forEach(key => {
|
fieldsToSync.forEach(key => {
|
||||||
if (localSettings[key] !== undefined) {
|
if (localSettings[key] !== undefined) {
|
||||||
if (key === 'base_model_path_mappings' || key === 'download_path_templates') {
|
payload[key] = localSettings[key];
|
||||||
payload[key] = JSON.stringify(localSettings[key]);
|
|
||||||
} else {
|
|
||||||
payload[key] = localSettings[key];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -546,7 +542,7 @@ export class SettingsManager {
|
|||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
base_model_path_mappings: JSON.stringify(state.global.settings.base_model_path_mappings)
|
base_model_path_mappings: state.global.settings.base_model_path_mappings
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -733,7 +729,7 @@ export class SettingsManager {
|
|||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
download_path_templates: JSON.stringify(state.global.settings.download_path_templates)
|
download_path_templates: state.global.settings.download_path_templates
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -868,7 +864,7 @@ export class SettingsManager {
|
|||||||
if (settingKey === 'default_lora_root' || settingKey === 'default_checkpoint_root' || settingKey === 'default_embedding_root' || settingKey === 'download_path_templates') {
|
if (settingKey === 'default_lora_root' || settingKey === 'default_checkpoint_root' || settingKey === 'default_embedding_root' || settingKey === 'download_path_templates') {
|
||||||
const payload = {};
|
const payload = {};
|
||||||
if (settingKey === 'download_path_templates') {
|
if (settingKey === 'download_path_templates') {
|
||||||
payload[settingKey] = JSON.stringify(state.global.settings.download_path_templates);
|
payload[settingKey] = state.global.settings.download_path_templates;
|
||||||
} else {
|
} else {
|
||||||
payload[settingKey] = value;
|
payload[settingKey] = value;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user