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,27 +67,35 @@ namespace Torch.Managers
if (!Torch.Config.GetPluginUpdates)
return;
var name = manifest.Repository.Split('/');
if (name.Length != 2)
try
{
_log.Error($"'{manifest.Repository}' is not a valid GitHub repository.");
return;
}
var name = manifest.Repository.Split('/');
if (name.Length != 2)
{
_log.Error($"'{manifest.Repository}' is not a valid GitHub repository.");
return;
}
var currentVersion = new Version(manifest.Version);
var releaseInfo = await GetLatestRelease(name[0], name[1]).ConfigureAwait(false);
if (releaseInfo.Item1 > currentVersion)
{
_log.Warn($"Updating {manifest.Repository} from version {currentVersion} to version {releaseInfo.Item1}");
var updateName = Path.Combine(_fsManager.TempDirectory, $"{name[0]}_{name[1]}.zip");
var updatePath = Path.Combine(_torchDir, "Plugins");
await new WebClient().DownloadFileTaskAsync(new Uri(releaseInfo.Item2), updateName).ConfigureAwait(false);
UpdateFromZip(updateName, updatePath);
File.Delete(updateName);
var currentVersion = new Version(manifest.Version);
var releaseInfo = await GetLatestRelease(name[0], name[1]).ConfigureAwait(false);
if (releaseInfo.Item1 > currentVersion)
{
_log.Warn($"Updating {manifest.Repository} from version {currentVersion} to version {releaseInfo.Item1}");
var updateName = Path.Combine(_fsManager.TempDirectory, $"{name[0]}_{name[1]}.zip");
var updatePath = Path.Combine(_torchDir, "Plugins");
await new WebClient().DownloadFileTaskAsync(new Uri(releaseInfo.Item2), updateName).ConfigureAwait(false);
UpdateFromZip(updateName, updatePath);
File.Delete(updateName);
}
else
{
_log.Info($"{manifest.Repository} is up to date. ({currentVersion})");
}
}
else
catch (Exception e)
{
_log.Info($"{manifest.Repository} is up to date. ({currentVersion})");
_log.Error($"An error occured downloading the plugin update for {manifest.Repository}.");
_log.Error(e);
}
}
@@ -96,18 +104,26 @@ namespace Torch.Managers
if (!Torch.Config.GetTorchUpdates)
return;
var releaseInfo = await GetLatestRelease("TorchAPI", "Torch").ConfigureAwait(false);
if (releaseInfo.Item1 > Torch.TorchVersion)
try
{
_log.Warn($"Updating Torch from version {Torch.TorchVersion} to version {releaseInfo.Item1}");
var updateName = Path.Combine(_fsManager.TempDirectory, "torchupdate.zip");
new WebClient().DownloadFile(new Uri(releaseInfo.Item2), updateName);
UpdateFromZip(updateName, _torchDir);
File.Delete(updateName);
var releaseInfo = await GetLatestRelease("TorchAPI", "Torch").ConfigureAwait(false);
if (releaseInfo.Item1 > Torch.TorchVersion)
{
_log.Warn($"Updating Torch from version {Torch.TorchVersion} to version {releaseInfo.Item1}");
var updateName = Path.Combine(_fsManager.TempDirectory, "torchupdate.zip");
new WebClient().DownloadFile(new Uri(releaseInfo.Item2), updateName);
UpdateFromZip(updateName, _torchDir);
File.Delete(updateName);
}
else
{
_log.Info("Torch is up to date.");
}
}
else
catch (Exception e)
{
_log.Info("Torch is up to date.");
_log.Error("An error occured downloading the Torch update.");
_log.Error(e);
}
}