statusicon: fix progress not appearing sometimes

This commit is contained in:
Hylke Bons 2012-11-18 14:29:10 +00:00
parent 2e73338337
commit 8e1c79226e
2 changed files with 17 additions and 32 deletions

View file

@ -246,23 +246,15 @@ namespace SparkleLib.Git {
// "Writing objects" stage // "Writing objects" stage
number = (number / 100 * 80 + 20); number = (number / 100 * 80 + 20);
if (line.Contains ("|")) { Regex speed_regex = new Regex (@"([0-9\.]+) ([KM])iB/s", RegexOptions.Compiled);
string s = line.Substring (line.IndexOf ("|") + 1).Trim (); Match speed_match = speed_regex.Match (line);
s = s.Replace (", done.", "").Trim ();
s = s.Replace ("KiB/s", "ᴋʙ/s");
s = s.Replace ("MiB/s", "ᴍʙ/s");
try { if (speed_match.Success) {
if (line.Contains ("KiB/s")) speed = double.Parse (speed_match.Groups [1].Value) * 1024;
speed = double.Parse (s);
if (line.Contains ("MiB/s")) if (speed_match.Groups [2].Value.Equals ("M"))
speed = double.Parse (s); speed = speed * 1024;
}
} catch {
speed = 0.0;
}
}
} }
} else { } else {
@ -338,23 +330,15 @@ namespace SparkleLib.Git {
} else { } else {
// "Writing objects" stage // "Writing objects" stage
number = (number / 100 * 80 + 20); number = (number / 100 * 80 + 20);
if (line.Contains ("|")) { Regex speed_regex = new Regex (@"([0-9\.]+) ([KM])iB/s", RegexOptions.Compiled);
string s = line.Substring (line.IndexOf ("|") + 1).Trim (); Match speed_match = speed_regex.Match (line);
s = s.Replace (", done.", "").Trim ();
s = s.Replace ("KiB/s", "ᴋʙ/s"); if (speed_match.Success) {
s = s.Replace ("MiB/s", "ᴍʙ/s"); speed = double.Parse (speed_match.Groups [1].Value) * 1024;
try { if (speed_match.Groups [2].Value.Equals ("M"))
if (line.Contains ("KiB/s")) speed = speed * 1024;
speed = double.Parse (s);
if (line.Contains ("MiB/s"))
speed = double.Parse (s);
} catch {
speed = 0.0;
}
} }
} }

View file

@ -336,6 +336,7 @@ namespace SparkleShare {
ProgressSpeedDown += rep.ProgressSpeed; ProgressSpeedDown += rep.ProgressSpeed;
} }
ProgressPercentage = percentage / repo_count;
UpdateState (); UpdateState ();
}; };