fetcher git: Proper scope for variable

This commit is contained in:
Hylke Bons 2015-01-13 22:20:50 +00:00
parent ffd67fbce8
commit 78eef8db5b

View file

@ -2,8 +2,8 @@
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com> // Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as // it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
@ -135,29 +135,29 @@ namespace SparkleLib.Git {
while (!this.git.StandardError.EndOfStream) { while (!this.git.StandardError.EndOfStream) {
string line = this.git.StandardError.ReadLine (); string line = this.git.StandardError.ReadLine ();
Match match = this.progress_regex.Match (line); Match match = this.progress_regex.Match (line);
double number = 0.0; double number = 0.0;
double speed = 0.0; double speed = 0.0;
if (match.Success) { if (match.Success) {
try { try {
number = double.Parse (match.Groups [1].Value, new CultureInfo ("en-US")); number = double.Parse (match.Groups [1].Value, new CultureInfo ("en-US"));
} catch (FormatException) { } catch (FormatException) {
SparkleLogger.LogInfo ("Git", "Error parsing progress: \"" + match.Groups [1] + "\""); SparkleLogger.LogInfo ("Git", "Error parsing progress: \"" + match.Groups [1] + "\"");
} }
// The pushing progress consists of two stages: the "Compressing // The pushing progress consists of two stages: the "Compressing
// objects" stage which we count as 20% of the total progress, and // objects" stage which we count as 20% of the total progress, and
// the "Writing objects" stage which we count as the last 80% // the "Writing objects" stage which we count as the last 80%
if (line.Contains ("Compressing")) { if (line.Contains ("Compressing")) {
// "Compressing objects" stage // "Compressing objects" stage
number = (number / 100 * 20); number = (number / 100 * 20);
} else { } else {
// "Writing objects" stage // "Writing objects" stage
number = (number / 100 * 80 + 20); number = (number / 100 * 80 + 20);
Match speed_match = this.speed_regex.Match (line); Match speed_match = this.speed_regex.Match (line);
if (speed_match.Success) { if (speed_match.Success) {
try { try {
speed = double.Parse (speed_match.Groups [1].Value, new CultureInfo ("en-US")) * 1024; speed = double.Parse (speed_match.Groups [1].Value, new CultureInfo ("en-US")) * 1024;
@ -165,10 +165,10 @@ namespace SparkleLib.Git {
} catch (FormatException) { } catch (FormatException) {
SparkleLogger.LogInfo ("Git", "Error parsing speed: \"" + speed_match.Groups [1] + "\""); SparkleLogger.LogInfo ("Git", "Error parsing speed: \"" + speed_match.Groups [1] + "\"");
} }
if (speed_match.Groups [2].Value.Equals ("M")) if (speed_match.Groups [2].Value.Equals ("M"))
speed = speed * 1024; speed = speed * 1024;
} }
} }
} else { } else {
@ -197,7 +197,7 @@ namespace SparkleLib.Git {
} }
} }
} }
} catch (Exception) { } catch (Exception) {
IsActive = false; IsActive = false;
return false; return false;
@ -308,7 +308,7 @@ namespace SparkleLib.Git {
if (process.ExitCode == 0) { if (process.ExitCode == 0) {
if (i > 0) if (i > 0)
crypto_password_is_hashed = false; this.crypto_password_is_hashed = false;
File.Delete (password_check_file_path); File.Delete (password_check_file_path);
return true; return true;
@ -337,7 +337,7 @@ namespace SparkleLib.Git {
try { try {
Directory.Delete (TargetFolder, true /* Recursive */ ); Directory.Delete (TargetFolder, true /* Recursive */ );
SparkleLogger.LogInfo ("Fetcher", "Deleted '" + TargetFolder + "'"); SparkleLogger.LogInfo ("Fetcher", "Deleted '" + TargetFolder + "'");
} catch (Exception e) { } catch (Exception e) {
SparkleLogger.LogInfo ("Fetcher", "Failed to delete '" + TargetFolder + "'", e); SparkleLogger.LogInfo ("Fetcher", "Failed to delete '" + TargetFolder + "'", e);
} }
@ -439,7 +439,7 @@ namespace SparkleLib.Git {
writer.WriteLine ("*." + extension + " -delta"); writer.WriteLine ("*." + extension + " -delta");
writer.WriteLine ("*." + extension.ToUpper () + " -delta"); writer.WriteLine ("*." + extension.ToUpper () + " -delta");
} }
writer.WriteLine ("*.txt text"); writer.WriteLine ("*.txt text");
writer.WriteLine ("*.TXT text"); writer.WriteLine ("*.TXT text");
} }