Skip to content

Commit

Permalink
repo: Improve handling of offline repos. Fixes #439
Browse files Browse the repository at this point in the history
  • Loading branch information
hbons committed Dec 3, 2011
1 parent d83df10 commit c01c852
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
8 changes: 5 additions & 3 deletions SparkleLib/Git/SparkleRepoGit.cs
Expand Up @@ -137,10 +137,12 @@ public override bool CheckForRemoteChanges ()

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 ();
Expand Down
9 changes: 6 additions & 3 deletions SparkleLib/SparkleRepoBase.cs
Expand Up @@ -116,7 +116,7 @@ public SparkleRepoBase (string path, SparkleBackend backend)

// 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 ();
};

Expand Down Expand Up @@ -180,7 +180,7 @@ protected void OnConflictResolved ()
}


public virtual bool CheckForRemoteChanges () // HasRemoteChanges { get; } ?
public virtual bool CheckForRemoteChanges () // TODO: HasRemoteChanges { get; }
{
return true;
}
Expand Down Expand Up @@ -432,8 +432,9 @@ private void SyncUpBase ()

HasUnsyncedChanges = true;
SyncDownBase ();
DisableWatching ();

if (SyncUp ()) {
if (this.server_online && SyncUp ()) {
HasUnsyncedChanges = false;

if (SyncStatusChanged != null)
Expand All @@ -442,6 +443,8 @@ private void SyncUpBase ()
this.listener.AnnounceBase (new SparkleAnnouncement (Identifier, CurrentRevision));

} else {
this.server_online = false;

if (SyncStatusChanged != null)
SyncStatusChanged (SyncStatus.Error);
}
Expand Down

0 comments on commit c01c852

Please sign in to comment.