- add: FallBack think
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
using Nebula.Shared.Models;
|
||||||
using Nebula.Shared.Services;
|
using Nebula.Shared.Services;
|
||||||
|
|
||||||
namespace Nebula.Shared;
|
namespace Nebula.Shared;
|
||||||
@@ -32,4 +33,9 @@ public static class CurrentConVar
|
|||||||
|
|
||||||
public static readonly ConVar<string[]> Favorites =
|
public static readonly ConVar<string[]> Favorites =
|
||||||
ConVarBuilder.Build<string[]>("server.favorites", []);
|
ConVarBuilder.Build<string[]>("server.favorites", []);
|
||||||
|
|
||||||
|
public static readonly ConVar<Dictionary<string, EngineVersionInfo>> EngineManifestBackup =
|
||||||
|
ConVarBuilder.Build<Dictionary<string, EngineVersionInfo>>("engine.manifest.backup");
|
||||||
|
public static readonly ConVar<ModulesInfo> ModuleManifestBackup =
|
||||||
|
ConVarBuilder.Build<ModulesInfo>("module.manifest.backup");
|
||||||
}
|
}
|
||||||
@@ -35,18 +35,52 @@ public sealed class EngineService
|
|||||||
|
|
||||||
public async Task LoadEngineManifest(CancellationToken cancellationToken)
|
public async Task LoadEngineManifest(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_debugService.Log("Fetching engine manifest from: " + CurrentConVar.EngineManifestUrl);
|
||||||
var info = await _restService.GetAsync<Dictionary<string, EngineVersionInfo>>(
|
var info = await _restService.GetAsync<Dictionary<string, EngineVersionInfo>>(
|
||||||
new Uri(_varService.GetConfigValue(CurrentConVar.EngineManifestUrl)!), cancellationToken);
|
new Uri(_varService.GetConfigValue(CurrentConVar.EngineManifestUrl)!), cancellationToken);
|
||||||
|
if (info.Value is null)
|
||||||
|
throw new Exception("Engine version info is null");
|
||||||
|
|
||||||
|
VersionInfos = info.Value;
|
||||||
|
|
||||||
|
_varService.SetConfigValue(CurrentConVar.EngineManifestBackup, info.Value);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_debugService.Debug("Trying fallback engine manifest...");
|
||||||
|
if (!_varService.TryGetConfigValue(CurrentConVar.EngineManifestBackup, out var engineInfo))
|
||||||
|
{
|
||||||
|
throw new Exception("No engine info data available",e);
|
||||||
|
}
|
||||||
|
|
||||||
|
VersionInfos = engineInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_debugService.Log("Fetching module manifest from: " + CurrentConVar.EngineModuleManifestUrl);
|
||||||
var moduleInfo = await _restService.GetAsync<ModulesInfo>(
|
var moduleInfo = await _restService.GetAsync<ModulesInfo>(
|
||||||
new Uri(_varService.GetConfigValue(CurrentConVar.EngineModuleManifestUrl)!), cancellationToken);
|
new Uri(_varService.GetConfigValue(CurrentConVar.EngineModuleManifestUrl)!), cancellationToken);
|
||||||
|
|
||||||
if (info.Value is null) return;
|
if (moduleInfo.Value is null)
|
||||||
VersionInfos = info.Value;
|
throw new Exception("Module version info is null");
|
||||||
|
|
||||||
if (moduleInfo.Value is null) return;
|
|
||||||
ModuleInfos = moduleInfo.Value.Modules;
|
ModuleInfos = moduleInfo.Value.Modules;
|
||||||
|
_varService.SetConfigValue(CurrentConVar.ModuleManifestBackup, moduleInfo.Value);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_debugService.Debug("Trying fallback module manifest...");
|
||||||
|
if (!_varService.TryGetConfigValue(CurrentConVar.ModuleManifestBackup, out var modulesInfo))
|
||||||
|
{
|
||||||
|
throw new Exception("No module info data available",e);
|
||||||
|
}
|
||||||
|
|
||||||
|
ModuleInfos = modulesInfo.Modules;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var f in ModuleInfos.Keys) _debugService.Debug(f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public EngineBuildInfo? GetVersionInfo(string version)
|
public EngineBuildInfo? GetVersionInfo(string version)
|
||||||
|
|||||||
Reference in New Issue
Block a user