repo: use accessors for HasUnsyncedChanges
This commit is contained in:
parent
80289b499a
commit
04cc6debfd
|
@ -50,7 +50,6 @@ namespace SparkleLib {
|
||||||
private bool is_syncing;
|
private bool is_syncing;
|
||||||
private bool is_buffering;
|
private bool is_buffering;
|
||||||
private bool is_polling;
|
private bool is_polling;
|
||||||
private bool has_unsynced_changes;
|
|
||||||
private bool server_online;
|
private bool server_online;
|
||||||
private SyncStatus status;
|
private SyncStatus status;
|
||||||
|
|
||||||
|
@ -88,9 +87,24 @@ namespace SparkleLib {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasUnsyncedChanges { // TODO: get/set this properly
|
public bool HasUnsyncedChanges {
|
||||||
get {
|
get {
|
||||||
return this.has_unsynced_changes;
|
string unsynced_file_path = SparkleHelpers.CombineMore (LocalPath,
|
||||||
|
".git", "has_unsynced_changes");
|
||||||
|
|
||||||
|
return File.Exists (unsynced_file_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
set {
|
||||||
|
string unsynced_file_path = SparkleHelpers.CombineMore (LocalPath,
|
||||||
|
".git", "has_unsynced_changes");
|
||||||
|
|
||||||
|
if (value) {
|
||||||
|
if (!File.Exists (unsynced_file_path))
|
||||||
|
File.Create (unsynced_file_path);
|
||||||
|
} else {
|
||||||
|
File.Delete (unsynced_file_path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,14 +160,6 @@ namespace SparkleLib {
|
||||||
else
|
else
|
||||||
this.revision = GetRevision ();
|
this.revision = GetRevision ();
|
||||||
|
|
||||||
string unsynced_file_path = SparkleHelpers.CombineMore (LocalPath,
|
|
||||||
".git", "has_unsynced_changes");
|
|
||||||
|
|
||||||
if (File.Exists (unsynced_file_path))
|
|
||||||
this.has_unsynced_changes = true;
|
|
||||||
else
|
|
||||||
this.has_unsynced_changes = false;
|
|
||||||
|
|
||||||
if (this.revision == null)
|
if (this.revision == null)
|
||||||
CreateInitialCommit ();
|
CreateInitialCommit ();
|
||||||
|
|
||||||
|
@ -190,7 +196,7 @@ namespace SparkleLib {
|
||||||
this.listener.Connect ();
|
this.listener.Connect ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.has_unsynced_changes)
|
if (HasUnsyncedChanges)
|
||||||
FetchRebaseAndPush ();
|
FetchRebaseAndPush ();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -202,7 +208,7 @@ namespace SparkleLib {
|
||||||
CheckForRemoteChanges ();
|
CheckForRemoteChanges ();
|
||||||
|
|
||||||
// Push changes that were made since the last disconnect
|
// Push changes that were made since the last disconnect
|
||||||
if (this.has_unsynced_changes)
|
if (HasUnsyncedChanges)
|
||||||
Push ();
|
Push ();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -677,13 +683,7 @@ namespace SparkleLib {
|
||||||
if (git.ExitCode != 0) {
|
if (git.ExitCode != 0) {
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes not pushed");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes not pushed");
|
||||||
|
|
||||||
string unsynced_file_path = SparkleHelpers.CombineMore (LocalPath ,
|
HasUnsyncedChanges = true;
|
||||||
".git", "has_unsynced_changes");
|
|
||||||
|
|
||||||
if (!File.Exists (unsynced_file_path))
|
|
||||||
File.Create (unsynced_file_path);
|
|
||||||
|
|
||||||
this.has_unsynced_changes = true;
|
|
||||||
|
|
||||||
if (SyncStatusChanged != null)
|
if (SyncStatusChanged != null)
|
||||||
SyncStatusChanged (SyncStatus.SyncUpFailed);
|
SyncStatusChanged (SyncStatus.SyncUpFailed);
|
||||||
|
@ -692,13 +692,7 @@ namespace SparkleLib {
|
||||||
} else {
|
} else {
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes pushed");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes pushed");
|
||||||
|
|
||||||
string unsynced_file_path = SparkleHelpers.CombineMore (LocalPath ,
|
HasUnsyncedChanges = false;
|
||||||
".git", "has_unsynced_changes");
|
|
||||||
|
|
||||||
if (File.Exists (unsynced_file_path))
|
|
||||||
File.Delete (unsynced_file_path);
|
|
||||||
|
|
||||||
this.has_unsynced_changes = false;
|
|
||||||
|
|
||||||
if (SyncStatusChanged != null)
|
if (SyncStatusChanged != null)
|
||||||
SyncStatusChanged (SyncStatus.SyncDownFinished);
|
SyncStatusChanged (SyncStatus.SyncDownFinished);
|
||||||
|
@ -985,7 +979,6 @@ namespace SparkleLib {
|
||||||
|
|
||||||
string n = Environment.NewLine;
|
string n = Environment.NewLine;
|
||||||
|
|
||||||
if (Added.Count > 0) {
|
|
||||||
foreach (string added in Added) {
|
foreach (string added in Added) {
|
||||||
file_name = added.Trim ("\"".ToCharArray ());
|
file_name = added.Trim ("\"".ToCharArray ());
|
||||||
message += "+ ‘" + file_name + "’" + n;
|
message += "+ ‘" + file_name + "’" + n;
|
||||||
|
@ -995,9 +988,6 @@ namespace SparkleLib {
|
||||||
return message + "...";
|
return message + "...";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Modified.Count > 0) {
|
|
||||||
foreach (string modified in Modified) {
|
foreach (string modified in Modified) {
|
||||||
file_name = modified.Trim ("\"".ToCharArray ());
|
file_name = modified.Trim ("\"".ToCharArray ());
|
||||||
message += "/ ‘" + file_name + "’" + n;
|
message += "/ ‘" + file_name + "’" + n;
|
||||||
|
@ -1006,9 +996,7 @@ namespace SparkleLib {
|
||||||
if (count == max_count)
|
if (count == max_count)
|
||||||
return message + "...";
|
return message + "...";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (Removed.Count > 0) {
|
|
||||||
foreach (string removed in Removed) {
|
foreach (string removed in Removed) {
|
||||||
file_name = removed.Trim ("\"".ToCharArray ());
|
file_name = removed.Trim ("\"".ToCharArray ());
|
||||||
message += "- ‘" + file_name + "’" + n;
|
message += "- ‘" + file_name + "’" + n;
|
||||||
|
@ -1018,8 +1006,6 @@ namespace SparkleLib {
|
||||||
return message + "..." + n;
|
return message + "..." + n;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue