diff --git a/SparkleLib/SparkleRepo.cs b/SparkleLib/SparkleRepo.cs index 80916f48..8497b563 100644 --- a/SparkleLib/SparkleRepo.cs +++ b/SparkleLib/SparkleRepo.cs @@ -76,6 +76,7 @@ namespace SparkleLib { private bool _IsFetching; private bool _IsPushing; private bool _HasUnsyncedChanges; + private bool _ServerOnline; /// @@ -173,6 +174,18 @@ namespace SparkleLib { } } + + /// + /// Indicates whether the remote repository is online, + /// this is based on the result of the Fetch method + /// + public bool ServerOnline { + get { + return _ServerOnline; + } + } + + /// /// Raised when local files have been added to the repository's staging area /// @@ -270,6 +283,7 @@ namespace SparkleLib { _IsPolling = true; _IsFetching = false; _IsPushing = false; + _ServerOnline = true; string unsynced_file_path = SparkleHelpers.CombineMore (LocalPath , ".git", "has_unsynced_changes"); @@ -654,6 +668,11 @@ namespace SparkleLib { _CurrentHash = GetCurrentHash (); + if (process.ExitCode != 0) + _ServerOnline = false; + else + _ServerOnline = true; + }; } @@ -805,10 +824,10 @@ namespace SparkleLib { string unsynced_file_path = SparkleHelpers.CombineMore (LocalPath , ".git", "has_unsynced_changes"); -// if (File.Exists (unsynced_file_path)) - // File.Delete (unsynced_file_path); TODO: restore + if (File.Exists (unsynced_file_path)) + File.Delete (unsynced_file_path); -// _HasUnsyncedChanges = false;TODO + _HasUnsyncedChanges = false; if (PushingFinished != null) PushingFinished (this, args); diff --git a/SparkleShare/SparkleLog.cs b/SparkleShare/SparkleLog.cs index ca40b71a..66f5627d 100644 --- a/SparkleShare/SparkleLog.cs +++ b/SparkleShare/SparkleLog.cs @@ -150,6 +150,8 @@ namespace SparkleShare { // Remove the eventhooks repo.NewCommit -= UpdateEventLog; repo.PushingFinished -= UpdateEventLog; + repo.PushingFailed -= UpdateEventLog; + repo.FetchingFinished -= UpdateEventLog; } @@ -193,6 +195,9 @@ namespace SparkleShare { // Update the log when changes are being sent repo.PushingFinished += UpdateEventLog; + repo.PushingFailed += UpdateEventLog; + + repo.FetchingFinished += UpdateEventLog; break; @@ -232,17 +237,34 @@ namespace SparkleShare { VBox layout_vertical = new VBox (false, 0); - - if ((SparkleUI.Repositories.Find (delegate (SparkleRepo r) - { return r.LocalPath.Equals (LocalPath); }) as SparkleRepo).HasUnsyncedChanges == true) { + if (SparkleUI.Repositories.Find ( + delegate (SparkleRepo r) + { return r.LocalPath.Equals (LocalPath) && r.HasUnsyncedChanges; } + ) != null) { string title = _("This folder has unsynced changes"); - string text = _("We will sync these once connected again"); + string text = _("We will sync these once we’re connected again"); SparkleInfobar infobar = new SparkleInfobar ("dialog-error", title, text); layout_vertical.PackStart (infobar, false, false, 0); + } else { + + if (SparkleUI.Repositories.Find ( + delegate (SparkleRepo r) + { return r.LocalPath.Equals (LocalPath) && r.HasUnsyncedChanges; } + ) != null) { + + string title = _("Could not sync with the remote folder"); + string text = _("Is the you and the server online?"); + + SparkleInfobar infobar = new SparkleInfobar ("dialog-error", title, text); + + layout_vertical.PackStart (infobar, false, false, 0); + + } + } TreeView tree_view = new TreeView ();