Merge pull request #415 from tgstation/414-VMismatchFix

Version usages fixes and improvements
This commit is contained in:
Jordan Brown
2017-11-25 17:20:23 -05:00
committed by GitHub
5 changed files with 47 additions and 20 deletions
+2 -10
View File
@@ -32,16 +32,8 @@ namespace TGS.ControlPanel
FormClosed += ControlPanel_FormClosed;
Interface = I;
if (Interface.IsRemoteConnection)
{
var splits = Interface.GetServiceComponent<ITGLanding>().Version().Split(' ');
Text = String.Format("TGS {0}: {1}:{2}", splits[splits.Length - 1], Interface.HTTPSURL, Interface.HTTPSPort);
}
Text += " Instance: " + I.InstanceName;
if (Interface.VersionMismatch(out string error) && MessageBox.Show(error, "Warning", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
{
Close();
return;
}
Text = String.Format("TGS {0}: {1}:{2}", Interface.ServerVersion, Interface.HTTPSURL, Interface.HTTPSPort);
Text = String.Format("{0} Instance: {1}", Text, I.InstanceName);
Panels.SelectedIndexChanged += Panels_SelectedIndexChanged;
Panels.SelectedIndex += Math.Min(Properties.Settings.Default.LastPageIndex, Panels.TabCount - 1);
InitRepoPage();
+4 -1
View File
@@ -73,7 +73,10 @@ namespace TGS.ControlPanel
MessageBox.Show("Authentication error: Username/password/windows identity is not authorized! Ensure you are a system administrator or in the correct Windows group on the service machine.");
return;
}
if (I.VersionMismatch(out error) && MessageBox.Show(error, "Warning", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
return;
new InstanceSelector(I).Show();
Close();
}
+1 -3
View File
@@ -79,9 +79,7 @@ namespace TGS.Installer.UI
var verifiedConnection = Interface.ConnectionStatus().HasFlag(ConnectivityLevel.Administrator);
try
{
VersionLabel.Text = Interface.GetServiceComponent<ITGSService>().Version();
var splits = VersionLabel.Text.Split(' ');
var realVersion = new Version(splits[splits.Length - 1].Substring(1));
var realVersion = Interface.ServerVersion;
var isV0 = realVersion < new Version(3, 1, 0, 0);
if (isV0) //OH GOD!!!!
MessageBox.Show("Upgrading from version 3.0 may trigger a bug that can delete /config and /data. IT IS STRONGLY RECCOMMENDED THAT YOU BACKUP THESE FOLDERS BEFORE UPDATING!", "Warning");
+39 -5
View File
@@ -16,6 +16,11 @@ namespace TGS.Interface
/// </summary>
public interface IServerInterface : IDisposable
{
/// <summary>
/// The <see cref="Version"/> of the connected <see cref="ITGSService"/>
/// </summary>
Version ServerVersion { get; }
/// <summary>
/// The name of the current instance in use. Defaults to <see langword="null"/>
/// </summary>
@@ -86,6 +91,11 @@ namespace TGS.Interface
/// </summary>
public static readonly IList<Type> ValidServiceInterfaces = new List<Type> { typeof(ITGSService), typeof(ITGInstanceManager), typeof(ITGConnectivity), typeof(ITGLanding) };
/// <summary>
/// Version of the interface
/// </summary>
public static readonly Version Version = Assembly.GetExecutingAssembly().GetName().Version;
/// <summary>
/// List of <see langword="interface"/>s that can be used with <see cref="GetComponent{T}"/>
/// </summary>
@@ -110,6 +120,33 @@ namespace TGS.Interface
/// </summary>
public const string InstanceInterfaceName = MasterInterfaceName + "/Instance";
/// <summary>
/// The <see cref="ServerVersion"/>
/// </summary>
Version _serverVersion;
/// <inheritdoc />
public Version ServerVersion { get
{
lock (this)
if (_serverVersion == null)
{
string rawVersion;
//check ITGSService first for compatiblity reasons
try
{
rawVersion = GetServiceComponent<ITGSService>().Version();
}
catch
{
rawVersion = GetServiceComponent<ITGLanding>().Version();
}
var splits = rawVersion.Split(' ');
_serverVersion = new Version(splits[splits.Length - 1].Substring(1));
}
return _serverVersion;
} }
/// <inheritdoc />
public string InstanceName { get; private set; }
@@ -296,12 +333,9 @@ namespace TGS.Interface
/// <inheritdoc />
public bool VersionMismatch(out string errorMessage)
{
var splits = GetServiceComponent<ITGLanding>().Version().Split(' ');
var theirs = new Version(splits[splits.Length - 1].Substring(1));
var ours = new Version(FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileVersion);
if(theirs.Major != ours.Major || theirs.Minor != ours.Minor || theirs.Revision != ours.Revision) //don't care about the patch level
if(ServerVersion.Major != Version.Major || ServerVersion.Minor != Version.Minor || ServerVersion.Build != Version.Build) //don't care about the patch level
{
errorMessage = String.Format("Version mismatch between interface version ({0}) and service version ({1}). Some functionality may crash this program.", ours, theirs);
errorMessage = String.Format("Version mismatch between interface version ({0}) and service version ({1}). Some functionality may crash this program.", Version, ServerVersion);
return true;
}
errorMessage = null;
+1 -1
View File
@@ -30,7 +30,7 @@ namespace TGS.Server
/// <summary>
/// The service version <see cref="string"/> based on the <see cref="FileVersionInfo"/>
/// </summary>
public static readonly string VersionString = "/tg/station 13 Server v" + FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;
public static readonly string VersionString = String.Format("/tg/station 13 Server v{0}", Assembly.GetExecutingAssembly().GetName().Version);
/// <summary>
/// Singleton <see cref="ILogger"/>