changeset 26:b5502ce8cb1f

Fix servers getting disabled at program launch if no SSH key is set, even if they have no SSH checks.
author Brad Greco <brad@bgreco.net>
date Sun, 02 Jun 2019 17:45:37 -0400
parents 781d8b980be1
children e59ec1585616
files ServerMonitor/Objects/Server.cs
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ServerMonitor/Objects/Server.cs	Thu May 30 21:41:14 2019 -0400
+++ b/ServerMonitor/Objects/Server.cs	Sun Jun 02 17:45:37 2019 -0400
@@ -111,7 +111,8 @@
                         // Disable the server until the user enters the decryption key,
                         // and set the KeyStatus to indicate why the server was disabled.
                         KeyStatus = KeyStatus.Closed;
-                        Enabled = false;
+                        if (HasSshChecks)
+                            Enabled = false;
                     }
                     else
                     {
@@ -139,7 +140,7 @@
                 // Do not allow enabling the server if the private key is not accessible.
                 // Do not fire the EnabledChanged event if the Enabled state is not actually changing
                 // from its existing value.
-                if ((LoginType == LoginType.PrivateKey && PrivateKeyFile == null && value == true && Checks.Any(c => c is SshCheck)) || value == _enabled)
+                if ((LoginType == LoginType.PrivateKey && PrivateKeyFile == null && value == true && HasSshChecks) || value == _enabled)
                     return;
                 _enabled = value;
                 EnabledChanged?.Invoke(this, new EventArgs());
@@ -176,6 +177,8 @@
             }
         }
 
+        public bool HasSshChecks => Checks.Any(c => c is SshCheck);
+
         /// <summary>Deletes a check from the server.</summary>
         /// <param name="check">The check to delete.</param>
         public void DeleteCheck(Check check)