ssh fetcher: Readability

This commit is contained in:
Hylke Bons 2018-03-10 12:32:33 +00:00
parent 05b5a3602d
commit 30fce55d38

View file

@ -34,6 +34,7 @@ namespace Sparkles {
public override bool Fetch () public override bool Fetch ()
{ {
string host_key = FetchHostKey (); string host_key = FetchHostKey ();
bool host_key_warning;
if (string.IsNullOrEmpty (RemoteUrl.Host) || host_key == null) { if (string.IsNullOrEmpty (RemoteUrl.Host) || host_key == null) {
Logger.LogInfo ("Auth", "Could not fetch host key"); Logger.LogInfo ("Auth", "Could not fetch host key");
@ -42,8 +43,6 @@ namespace Sparkles {
return false; return false;
} }
bool warn = true;
if (RequiredFingerprint != null) { if (RequiredFingerprint != null) {
string host_fingerprint; string host_fingerprint;
@ -59,22 +58,21 @@ namespace Sparkles {
return false; return false;
} }
if (host_fingerprint == null || !RequiredFingerprint.Equals (host_fingerprint)) { if (host_fingerprint == null || RequiredFingerprint!= host_fingerprint) {
Logger.LogInfo ("Auth", "Fingerprint doesn't match"); Logger.LogInfo ("Auth", "Fingerprint doesn't match");
errors.Add ("error: Host fingerprint doesn't match"); errors.Add ("error: Host fingerprint doesn't match");
return false; return false;
} }
warn = false;
Logger.LogInfo ("Auth", "Fingerprint matches"); Logger.LogInfo ("Auth", "Fingerprint matches");
} else { } else {
Logger.LogInfo ("Auth", "Skipping fingerprint check"); Logger.LogInfo ("Auth", "Skipping fingerprint check");
host_key_warning = true;
} }
AcceptHostKey (host_key, warn); AcceptHostKey (host_key, host_key_warning);
return true; return true;
} }