fetcher: log exceptions more cleanly
This commit is contained in:
parent
3b51e0b315
commit
0c3905e58a
|
@ -294,7 +294,7 @@ namespace SparkleLib.Git {
|
|||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
SparkleLogger.LogInfo ("Fetcher", "Failed to dispose properly: " + e.Message);
|
||||
SparkleLogger.LogInfo ("Fetcher", "Failed to dispose properly", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -411,8 +411,6 @@ namespace SparkleLib.Git {
|
|||
{
|
||||
SparkleGit git = new SparkleGit (LocalPath, "add --all");
|
||||
git.StartAndWaitForExit ();
|
||||
|
||||
SparkleLogger.LogInfo ("Git", Name + " | Changes staged");
|
||||
}
|
||||
|
||||
|
||||
|
@ -533,9 +531,7 @@ namespace SparkleLib.Git {
|
|||
SparkleLogger.LogInfo ("Git", Name + " | Conflict type: " + line);
|
||||
|
||||
// Ignore conflicts in the .sparkleshare file and use the local version
|
||||
if (conflicting_path.EndsWith (".sparkleshare") ||
|
||||
conflicting_path.EndsWith (".empty")) {
|
||||
|
||||
if (conflicting_path.EndsWith (".sparkleshare") || conflicting_path.EndsWith (".empty")) {
|
||||
// Recover local version
|
||||
SparkleGit git_theirs = new SparkleGit (LocalPath, "checkout --theirs \"" + conflicting_path + "\"");
|
||||
git_theirs.StartAndWaitForExit ();
|
||||
|
@ -574,12 +570,8 @@ namespace SparkleLib.Git {
|
|||
|
||||
// The local version has been modified, but the server version was removed
|
||||
} else if (line.StartsWith ("DU")) {
|
||||
|
||||
// The modified local version is already in the
|
||||
// checkout, so it just needs to be added.
|
||||
//
|
||||
// We need to specifically mention the file, so
|
||||
// we can't reuse the Add () method
|
||||
// The modified local version is already in the checkout, so it just needs to be added.
|
||||
// We need to specifically mention the file, so we can't reuse the Add () method
|
||||
SparkleGit git_add = new SparkleGit (LocalPath, "add \"" + conflicting_path + "\"");
|
||||
git_add.StartAndWaitForExit ();
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace SparkleLib {
|
|||
else if (byte_count >= 1024)
|
||||
return String.Format ("{0:##.##} ᴋʙ", Math.Round (byte_count / 1024, 0));
|
||||
else
|
||||
return byte_count.ToString () + " bytes";
|
||||
return byte_count.ToString () + " ʙ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,8 +162,8 @@ namespace SparkleLib {
|
|||
|
||||
IsActive = false;
|
||||
|
||||
bool repo_is_encrypted =
|
||||
(RemoteUrl.AbsolutePath.Contains ("-crypto") || RemoteUrl.Host.Equals ("sparkleshare.net"));
|
||||
bool repo_is_encrypted = (RemoteUrl.AbsolutePath.Contains ("-crypto") ||
|
||||
RemoteUrl.Host.Equals ("sparkleshare.net"));
|
||||
|
||||
Finished (repo_is_encrypted, IsFetchedRepoEmpty, Warnings);
|
||||
|
||||
|
@ -257,29 +257,22 @@ namespace SparkleLib {
|
|||
|
||||
private string FetchHostKey ()
|
||||
{
|
||||
string host = RemoteUrl.Host;
|
||||
int port = RemoteUrl.Port;
|
||||
|
||||
if (port < 1)
|
||||
port = 22;
|
||||
|
||||
SparkleLogger.LogInfo ("Auth", "Fetching host key for " + host);
|
||||
|
||||
Process process = new Process () {
|
||||
EnableRaisingEvents = true
|
||||
};
|
||||
SparkleLogger.LogInfo ("Auth", "Fetching host key for " + RemoteUrl.Host);
|
||||
|
||||
Process process = new Process ();
|
||||
process.StartInfo.FileName = "ssh-keyscan";
|
||||
process.StartInfo.Arguments = "-t rsa -p " + port + " " + host;
|
||||
process.StartInfo.WorkingDirectory = SparkleConfig.DefaultConfig.TmpPath;
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
process.StartInfo.RedirectStandardOutput = true;
|
||||
process.StartInfo.CreateNoWindow = true;
|
||||
process.EnableRaisingEvents = true;
|
||||
|
||||
if (RemoteUrl.Port < 1)
|
||||
process.StartInfo.Arguments = "-t rsa -p 22 " + RemoteUrl.Host;
|
||||
else
|
||||
process.StartInfo.Arguments = "-t rsa -p " + RemoteUrl.Port + " " + RemoteUrl.Host;
|
||||
|
||||
process.Start ();
|
||||
|
||||
// Reading the standard output HAS to go before
|
||||
// WaitForExit, or it will hang forever on output > 4096 bytes
|
||||
string host_key = process.StandardOutput.ReadToEnd ().Trim ();
|
||||
process.WaitForExit ();
|
||||
|
||||
|
@ -302,7 +295,7 @@ namespace SparkleLib {
|
|||
return fingerprint.ToLower ().Replace ("-", ":");
|
||||
|
||||
} catch (Exception e) {
|
||||
SparkleLogger.LogInfo ("Fetcher", "Failed creating fingerprint: " + e.Message + e.StackTrace);
|
||||
SparkleLogger.LogInfo ("Fetcher", "Failed creating fingerprint: " + e.Message + " " + e.StackTrace);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,10 +26,19 @@ namespace SparkleLib {
|
|||
private static int log_size = 0;
|
||||
|
||||
public static void LogInfo (string type, string message)
|
||||
{
|
||||
LogInfo (type, message, null);
|
||||
}
|
||||
|
||||
|
||||
public static void LogInfo (string type, string message, Exception exception)
|
||||
{
|
||||
string timestamp = DateTime.Now.ToString ("HH:mm:ss");
|
||||
string line = timestamp + " | " + type + " | " + message;
|
||||
|
||||
if (exception != null)
|
||||
line += ": " + exception.Message + " " + exception.StackTrace;
|
||||
|
||||
if (SparkleConfig.DebugMode)
|
||||
Console.WriteLine (line);
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ namespace SparkleShare {
|
|||
|
||||
private void HideDockIcon ()
|
||||
{
|
||||
// Currently not supported, here for completeness sake (see Apple's docs)
|
||||
// Currently not supported by Apple's API
|
||||
// NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.None;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue