fetcher git: Catch stream errors when process has been killed by user. Fixes #1187

This commit is contained in:
Hylke Bons 2013-06-20 21:01:03 +01:00
parent 064fe7f00d
commit 711811f13d
2 changed files with 50 additions and 39 deletions

View file

@ -128,6 +128,7 @@ namespace SparkleLib.Git {
DateTime last_change = DateTime.Now;
TimeSpan change_interval = new TimeSpan (0, 0, 0, 1);
try {
while (!this.git.StandardError.EndOfStream) {
string line = this.git.StandardError.ReadLine ();
Match match = progress_regex.Match (line);
@ -171,6 +172,11 @@ namespace SparkleLib.Git {
}
}
} catch (Exception e) {
IsActive = false;
return false;
}
this.git.WaitForExit ();
if (this.git.ExitCode == 0) {
@ -277,8 +283,7 @@ namespace SparkleLib.Git {
public override void Stop ()
{
try {
if (this.git != null) {
this.git.Close ();
if (this.git != null && !this.git.HasExited) {
this.git.Kill ();
this.git.Dispose ();
}

View file

@ -56,7 +56,7 @@ namespace SparkleLib {
public string RequiredFingerprint { get; protected set; }
public readonly bool FetchPriorHistory = false;
public string TargetFolder { get; protected set; }
public bool IsActive { get; private set; }
public bool IsActive { get; protected set; }
public string Identifier;
public SparkleFetcherInfo OriginalFetcherInfo;
@ -150,10 +150,16 @@ namespace SparkleLib {
} else {
Thread.Sleep (500);
if (IsActive) {
SparkleLogger.LogInfo ("Fetcher", "Failed");
Failed ();
} else {
SparkleLogger.LogInfo ("Fetcher", "Failed: cancelled by user");
}
IsActive = false;
Failed ();
}
});