- add: FallBack think
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Nebula.Shared.Models;
|
||||
using Nebula.Shared.Services;
|
||||
|
||||
namespace Nebula.Shared;
|
||||
@@ -32,4 +33,9 @@ public static class CurrentConVar
|
||||
|
||||
public static readonly ConVar<string[]> 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)
|
||||
{
|
||||
var info = await _restService.GetAsync<Dictionary<string, EngineVersionInfo>>(
|
||||
new Uri(_varService.GetConfigValue(CurrentConVar.EngineManifestUrl)!), cancellationToken);
|
||||
var moduleInfo = await _restService.GetAsync<ModulesInfo>(
|
||||
new Uri(_varService.GetConfigValue(CurrentConVar.EngineModuleManifestUrl)!), cancellationToken);
|
||||
try
|
||||
{
|
||||
_debugService.Log("Fetching engine manifest from: " + CurrentConVar.EngineManifestUrl);
|
||||
var info = await _restService.GetAsync<Dictionary<string, EngineVersionInfo>>(
|
||||
new Uri(_varService.GetConfigValue(CurrentConVar.EngineManifestUrl)!), cancellationToken);
|
||||
if (info.Value is null)
|
||||
throw new Exception("Engine version info is null");
|
||||
|
||||
if (info.Value is null) return;
|
||||
VersionInfos = info.Value;
|
||||
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);
|
||||
}
|
||||
|
||||
if (moduleInfo.Value is null) return;
|
||||
ModuleInfos = moduleInfo.Value.Modules;
|
||||
VersionInfos = engineInfo;
|
||||
}
|
||||
|
||||
foreach (var f in ModuleInfos.Keys) _debugService.Debug(f);
|
||||
try
|
||||
{
|
||||
_debugService.Log("Fetching module manifest from: " + CurrentConVar.EngineModuleManifestUrl);
|
||||
var moduleInfo = await _restService.GetAsync<ModulesInfo>(
|
||||
new Uri(_varService.GetConfigValue(CurrentConVar.EngineModuleManifestUrl)!), cancellationToken);
|
||||
|
||||
if (moduleInfo.Value is null)
|
||||
throw new Exception("Module version info is null");
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public EngineBuildInfo? GetVersionInfo(string version)
|
||||
|
||||
Reference in New Issue
Block a user