From 9a3e34381c5992e96ce56012083d52c254643a0c Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sat, 3 Dec 2011 12:40:03 +0100 Subject: [PATCH] repo: Improve handling of offline repos. Fixes #439 --- SparkleLib/Git/SparkleRepoGit.cs | 8 +++++--- SparkleLib/SparkleRepoBase.cs | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/SparkleLib/Git/SparkleRepoGit.cs b/SparkleLib/Git/SparkleRepoGit.cs index 9025c575..67d487d5 100755 --- a/SparkleLib/Git/SparkleRepoGit.cs +++ b/SparkleLib/Git/SparkleRepoGit.cs @@ -137,10 +137,12 @@ namespace SparkleLib { public override bool SyncUp () { - Add (); + if (AnyDifferences) { + Add (); - string message = FormatCommitMessage (); - Commit (message); + string message = FormatCommitMessage (); + Commit (message); + } SparkleGit git = new SparkleGit (LocalPath, "push origin master"); git.Start (); diff --git a/SparkleLib/SparkleRepoBase.cs b/SparkleLib/SparkleRepoBase.cs index f9f8087e..4be397e5 100755 --- a/SparkleLib/SparkleRepoBase.cs +++ b/SparkleLib/SparkleRepoBase.cs @@ -116,7 +116,7 @@ namespace SparkleLib { // In the unlikely case that we haven't synced up our // changes or the server was down, sync up again - if (HasUnsyncedChanges) + if (HasUnsyncedChanges && !IsSyncing && this.server_online) SyncUpBase (); }; @@ -180,7 +180,7 @@ namespace SparkleLib { } - public virtual bool CheckForRemoteChanges () // HasRemoteChanges { get; } ? + public virtual bool CheckForRemoteChanges () // TODO: HasRemoteChanges { get; } { return true; } @@ -432,8 +432,9 @@ namespace SparkleLib { HasUnsyncedChanges = true; SyncDownBase (); + DisableWatching (); - if (SyncUp ()) { + if (this.server_online && SyncUp ()) { HasUnsyncedChanges = false; if (SyncStatusChanged != null) @@ -442,6 +443,8 @@ namespace SparkleLib { this.listener.AnnounceBase (new SparkleAnnouncement (Identifier, CurrentRevision)); } else { + this.server_online = false; + if (SyncStatusChanged != null) SyncStatusChanged (SyncStatus.Error); }