Catch errors in updater and fix loading error

This commit is contained in:
John Gross
2017-08-01 13:01:10 -07:00
parent 42bb24ca6a
commit 97da740e7e
6 changed files with 58 additions and 38 deletions

View File

@@ -1,4 +1,4 @@
using System.Reflection;
[assembly: AssemblyVersion("1.0.212.393")]
[assembly: AssemblyFileVersion("1.0.212.393")]
[assembly: AssemblyVersion("1.0.213.390")]
[assembly: AssemblyFileVersion("1.0.213.390")]

View File

@@ -34,7 +34,10 @@ namespace Torch.Server.Managers
/// <inheritdoc />
public override void Init()
{
LoadInstance(Torch.Config.InstancePath);
MyFileSystem.ExePath = Path.Combine(Torch.GetManager<FilesystemManager>().TorchDirectory, "DedicatedServer64");
MyFileSystem.Init("Content", Torch.Config.InstancePath);
//Initializes saves path. Why this isn't in Init() we may never know.
MyFileSystem.InitUserSpecific(null);
}
public void LoadInstance(string path, bool validate = true)
@@ -70,7 +73,7 @@ namespace Torch.Server.Managers
return;
}
LoadWorldMods();
ImportWorldConfig();
/*
if (string.IsNullOrEmpty(DedicatedConfig.LoadWorld))
@@ -83,11 +86,11 @@ namespace Torch.Server.Managers
public void SelectWorld(string worldPath, bool modsOnly = true)
{
DedicatedConfig.LoadWorld = worldPath;
LoadWorldMods(modsOnly);
ImportWorldConfig(modsOnly);
}
private void LoadWorldMods(bool modsOnly = true)
private void ImportWorldConfig(bool modsOnly = true)
{
if (string.IsNullOrEmpty(DedicatedConfig.LoadWorld))
return;
@@ -112,14 +115,14 @@ namespace Torch.Server.Managers
DedicatedConfig.Mods = sb.ToString();
Log.Info("Loaded mod list from world");
Log.Debug("Loaded mod list from world");
if (!modsOnly)
DedicatedConfig.SessionSettings = new SessionSettingsViewModel(checkpoint.Settings);
}
catch (Exception e)
{
Log.Error($"Error loading mod list from world '{DedicatedConfig.LoadWorld}'.");
Log.Error($"Error loading mod list from world, verify that your mod list is accurate. '{DedicatedConfig.LoadWorld}'.");
Log.Error(e);
}
}

View File

@@ -1,4 +1,4 @@
using System.Reflection;
[assembly: AssemblyVersion("1.1.212.393")]
[assembly: AssemblyFileVersion("1.1.212.393")]
[assembly: AssemblyVersion("1.1.213.390")]
[assembly: AssemblyFileVersion("1.1.213.390")]

View File

@@ -67,7 +67,6 @@ namespace Torch.Server
public override void Init()
{
Log.Info($"Init server '{Config.InstanceName}' at '{Config.InstancePath}'");
MyObjectBuilderSerializer.RegisterFromAssembly(typeof(MyObjectBuilder_CheckpointSerializer).Assembly);
base.Init();
MyPerGameSettings.SendLogToKeen = false;
@@ -80,6 +79,7 @@ namespace Torch.Server
MyFinalBuildConstants.APP_VERSION = MyPerGameSettings.BasicGameInfo.GameVersion;
InvokeBeforeRun();
MyObjectBuilderSerializer.RegisterFromAssembly(typeof(MyObjectBuilder_CheckpointSerializer).Assembly);
MyPlugins.RegisterGameAssemblyFile(MyPerGameSettings.GameModAssembly);
MyPlugins.RegisterGameObjectBuildersAssemblyFile(MyPerGameSettings.GameModObjBuildersAssembly);
MyPlugins.RegisterSandboxAssemblyFile(MyPerGameSettings.SandboxAssembly);
@@ -87,6 +87,7 @@ namespace Torch.Server
MyPlugins.Load();
MyGlobalTypeMetadata.Static.Init();
GetManager<InstanceManager>().LoadInstance(Config.InstancePath);
Plugins.LoadPlugins();
}

View File

@@ -39,7 +39,7 @@
</StackPanel>
<TabControl Grid.Row="1" Height="Auto" x:Name="TabControl" Margin="5,0,5,5">
<TabItem Header="Configuration">
<Grid>
<Grid IsEnabled="{Binding IsRunning, Converter={StaticResource InverseBool}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>

View File

@@ -67,6 +67,8 @@ namespace Torch.Managers
if (!Torch.Config.GetPluginUpdates)
return;
try
{
var name = manifest.Repository.Split('/');
if (name.Length != 2)
{
@@ -90,12 +92,20 @@ namespace Torch.Managers
_log.Info($"{manifest.Repository} is up to date. ({currentVersion})");
}
}
catch (Exception e)
{
_log.Error($"An error occured downloading the plugin update for {manifest.Repository}.");
_log.Error(e);
}
}
private async void CheckAndUpdateTorch()
{
if (!Torch.Config.GetTorchUpdates)
return;
try
{
var releaseInfo = await GetLatestRelease("TorchAPI", "Torch").ConfigureAwait(false);
if (releaseInfo.Item1 > Torch.TorchVersion)
{
@@ -110,6 +120,12 @@ namespace Torch.Managers
_log.Info("Torch is up to date.");
}
}
catch (Exception e)
{
_log.Error("An error occured downloading the Torch update.");
_log.Error(e);
}
}
private void UpdateFromZip(string zipFile, string extractPath)
{