diff --git a/SparkleLib/Git/SparkleFetcherGit.cs b/SparkleLib/Git/SparkleFetcherGit.cs index 1ef1ef24..b84e7c93 100755 --- a/SparkleLib/Git/SparkleFetcherGit.cs +++ b/SparkleLib/Git/SparkleFetcherGit.cs @@ -42,13 +42,10 @@ namespace SparkleLib.Git { SparkleGit git = new SparkleGit (TargetFolder, "ls-remote --heads"); string branches = git.StartAndReadStandardOutput (); Regex salt_regex = new Regex ("refs/heads/salt-([0-9a-f]+)"); - Match salt_match = salt_regex.Match (branches); - if (salt_match.Success) { + if (salt_match.Success) this.cached_salt = salt_match.Groups [1].Value; - SparkleLogger.LogInfo ("SALT", salt_match.Groups [1].Value); - } // ...if not, create a new salt for the repo if (string.IsNullOrEmpty (this.cached_salt)) { diff --git a/SparkleLib/Git/SparkleRepoGit.cs b/SparkleLib/Git/SparkleRepoGit.cs index 0d50c8e3..bcc4a14d 100644 --- a/SparkleLib/Git/SparkleRepoGit.cs +++ b/SparkleLib/Git/SparkleRepoGit.cs @@ -46,22 +46,23 @@ namespace SparkleLib.Git { private string branch { get { - if (string.IsNullOrEmpty (this.cached_branch)) { - string rebase_apply_path = new string [] { LocalPath, ".git", "rebase-apply" }.Combine (); + if (!string.IsNullOrEmpty (this.cached_branch)) + return this.cached_branch; - while (Directory.Exists (rebase_apply_path) && HasLocalChanges) { - try { - ResolveConflict (); - - } catch (IOException e) { - SparkleLogger.LogInfo ("Git", Name + " | Failed to resolve conflict, trying again... (" + e.Message + ")"); - } + string rebase_apply_path = new string [] { LocalPath, ".git", "rebase-apply" }.Combine (); + + while (Directory.Exists (rebase_apply_path) && HasLocalChanges) { + try { + ResolveConflict (); + + } catch (IOException e) { + SparkleLogger.LogInfo ("Git", Name + " | Failed to resolve conflict, trying again...", e); } - - SparkleGit git = new SparkleGit (LocalPath, "rev-parse --abbrev-ref HEAD"); - this.cached_branch = git.StartAndReadStandardOutput (); } + SparkleGit git = new SparkleGit (LocalPath, "rev-parse --abbrev-ref HEAD"); + this.cached_branch = git.StartAndReadStandardOutput (); + return this.cached_branch; } } @@ -480,7 +481,7 @@ namespace SparkleLib.Git { ResolveConflict (); } catch (IOException e) { - SparkleLogger.LogInfo ("Git", Name + " | Failed to resolve conflict, trying again... (" + e.Message + ")"); + SparkleLogger.LogInfo ("Git", Name + " | Failed to resolve conflict, trying again...", e); } } @@ -967,7 +968,7 @@ namespace SparkleLib.Git { } } catch (IOException e) { - SparkleLogger.LogInfo ("Git", "Failed preparing directory: " + e.Message); + SparkleLogger.LogInfo ("Git", "Failed preparing directory", e); } } @@ -1043,7 +1044,7 @@ namespace SparkleLib.Git { } } catch (Exception e) { - SparkleLogger.LogInfo ("Local", "Error calculating size: " + e.Message); + SparkleLogger.LogInfo ("Local", "Error calculating size", e); return 0; } @@ -1053,7 +1054,7 @@ namespace SparkleLib.Git { size += CalculateSizes (directory); } catch (Exception e) { - SparkleLogger.LogInfo ("Local", "Error calculating size: " + e.Message); + SparkleLogger.LogInfo ("Local", "Error calculating size", e); return 0; } diff --git a/SparkleLib/SparkleRepoBase.cs b/SparkleLib/SparkleRepoBase.cs index 7305017e..1a87d37c 100755 --- a/SparkleLib/SparkleRepoBase.cs +++ b/SparkleLib/SparkleRepoBase.cs @@ -147,6 +147,8 @@ namespace SparkleLib { public SparkleRepoBase (string path, SparkleConfig config) { + SparkleLogger.LogInfo (path, "Initializing..."); + Status = SyncStatus.Idle; Error = ErrorStatus.None; this.local_config = config; diff --git a/SparkleShare/SparkleControllerBase.cs b/SparkleShare/SparkleControllerBase.cs index de4ae5cc..df5c182a 100644 --- a/SparkleShare/SparkleControllerBase.cs +++ b/SparkleShare/SparkleControllerBase.cs @@ -386,13 +386,10 @@ namespace SparkleShare { try { repo = (SparkleRepoBase) Activator.CreateInstance ( Type.GetType ("SparkleLib." + backend + ".SparkleRepo, SparkleLib." + backend), - new object [] { folder_path, this.config } - ); + new object [] { folder_path, this.config }); } catch (Exception e) { - SparkleLogger.LogInfo ("Controller", - "Failed to load '" + backend + "' backend for '" + folder_name + "': " + e.Message); - + SparkleLogger.LogInfo ("Controller", "Failed to load backend '" + backend + "' for '" + folder_name + "': ", e); return; } diff --git a/SparkleShare/SparkleStatusIconController.cs b/SparkleShare/SparkleStatusIconController.cs index 6dd5bf25..0864457f 100755 --- a/SparkleShare/SparkleStatusIconController.cs +++ b/SparkleShare/SparkleStatusIconController.cs @@ -93,18 +93,18 @@ namespace SparkleShare { } } - public bool QuitItemEnabled { - get { - return (CurrentState == IconState.Idle || CurrentState == IconState.Error); - } - } - public bool RecentEventsItemEnabled { get { return (Program.Controller.Folders.Count > 0); } } + public bool QuitItemEnabled { + get { + return (CurrentState == IconState.Idle || CurrentState == IconState.Error); + } + } + public SparkleStatusIconController () { @@ -138,8 +138,6 @@ namespace SparkleShare { StateText = "Projects up to date " + FolderSize; } - UpdateQuitItemEvent (QuitItemEnabled); - UpdateStatusItemEvent (StateText); UpdateIconEvent (CurrentState); UpdateMenuEvent (CurrentState); }; @@ -185,8 +183,6 @@ namespace SparkleShare { UpdateFolders (); - UpdateQuitItemEvent (QuitItemEnabled); - UpdateStatusItemEvent (StateText); UpdateIconEvent (CurrentState); UpdateMenuEvent (CurrentState); }; @@ -206,6 +202,18 @@ namespace SparkleShare { new Thread (() => repo.ForceRetry ()).Start (); } + + public EventHandler OpenFolderDelegate (string subfolder) + { + return delegate { SubfolderClicked (subfolder); }; + } + + + public EventHandler TryAgainDelegate (string subfolder) + { + return delegate { TryAgainClicked (subfolder); }; + } + public void RecentEventsClicked (object sender, EventArgs args) { @@ -237,18 +245,6 @@ namespace SparkleShare { } - public EventHandler OpenFolderDelegate (string subfolder) - { - return delegate { SubfolderClicked (subfolder); }; - } - - - public EventHandler TryAgainDelegate (string subfolder) - { - return delegate { TryAgainClicked (subfolder); }; - } - - private void UpdateFolders () { Folders = Program.Controller.Folders.ToArray ();