mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-08-31 10:58:28 +00:00
fix(config): correctly detect v1 vs v2 config and preserve versions node
- Determine config version by presence of "system" and "template" nodes instead of "versions", since a v2 config can also include "versions" and was previously being skipped from merging as a result. - Preserve the "versions" node after merging a v1 config, since PortalConfigReader.MergeConfigs does not carry it forward.
This commit is contained in:
parent
2f7789b374
commit
47e186d8f4
1 changed files with 17 additions and 6 deletions
|
|
@ -135,12 +135,14 @@ namespace PepperDash.Essentials.Core.Config
|
|||
{
|
||||
var parsedConfig = JObject.Parse(fs.ReadToEnd());
|
||||
|
||||
// Check if it's a v2 config (check for "version" node)
|
||||
// this means it's already merged by the Portal API
|
||||
// from the v2 config tool
|
||||
var isV2Config = parsedConfig["versions"] != null;
|
||||
// A config is v1 if it has separate "system" and "template" nodes that
|
||||
// need to be merged. A v2 config is already merged by the Portal API and
|
||||
// will not have "system"/"template" nodes. This is independent of whether
|
||||
// a "versions" node is present, which only carries version metadata and
|
||||
// can appear on either a v1 or v2 config.
|
||||
var isV1Config = parsedConfig["system"] != null && parsedConfig["template"] != null;
|
||||
|
||||
if (isV2Config)
|
||||
if (!isV1Config)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "Config file is a v2 format, no merge necessary.");
|
||||
ConfigObject = parsedConfig.ToObject<EssentialsConfig>();
|
||||
|
|
@ -148,6 +150,8 @@ namespace PepperDash.Essentials.Core.Config
|
|||
return true;
|
||||
}
|
||||
|
||||
Debug.LogMessage(LogEventLevel.Information, "Config file is a v1 format, merging system and template.");
|
||||
|
||||
// Extract SystemUrl and TemplateUrl into final config output
|
||||
ConfigObject = PortalConfigReader.MergeConfigs(parsedConfig).ToObject<EssentialsConfig>();
|
||||
|
||||
|
|
@ -160,6 +164,13 @@ namespace PepperDash.Essentials.Core.Config
|
|||
{
|
||||
ConfigObject.TemplateUrl = parsedConfig["template_url"].Value<string>();
|
||||
}
|
||||
|
||||
// MergeConfigs does not carry the "versions" node forward, so it must be
|
||||
// applied separately to ensure it's preserved in the merged config.
|
||||
if (parsedConfig["versions"] != null)
|
||||
{
|
||||
ConfigObject.Versions = parsedConfig["versions"].ToObject<VersionData>();
|
||||
}
|
||||
}
|
||||
|
||||
Debug.LogMessage(LogEventLevel.Information, "Successfully Loaded Merged Config");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue