repo: fix coding style for private members
This commit is contained in:
parent
5cf545ab0c
commit
3322e46fc9
|
@ -29,23 +29,24 @@ namespace SparkleLib {
|
||||||
|
|
||||||
public class SparkleRepo {
|
public class SparkleRepo {
|
||||||
|
|
||||||
private Timer RemoteTimer;
|
private Timer remote_timer;
|
||||||
private Timer LocalTimer;
|
private Timer local_timer;
|
||||||
private FileSystemWatcher Watcher;
|
private FileSystemWatcher watcher;
|
||||||
private System.Object ChangeLock;
|
private System.Object change_lock;
|
||||||
private int FetchQueue;
|
private int fetch_queue;
|
||||||
private int AnnounceQueue;
|
private int announce_queue;
|
||||||
private SparkleListener Listener;
|
private SparkleListener listener;
|
||||||
private List <double> SizeBuffer;
|
private List <double> sizebuffer;
|
||||||
private bool HasChanged;
|
private bool has_changed;
|
||||||
private string _CurrentHash;
|
|
||||||
private bool _IsSyncing;
|
private string current_hash;
|
||||||
private bool _IsBuffering;
|
private bool is_syncing;
|
||||||
private bool _IsPolling;
|
private bool is_buffering;
|
||||||
private bool _IsFetching;
|
private bool is_polling;
|
||||||
private bool _IsPushing;
|
private bool is_fetching;
|
||||||
private bool _HasUnsyncedChanges;
|
private bool is_pushing;
|
||||||
private bool _ServerOnline;
|
private bool has_unsynced_changes;
|
||||||
|
private bool server_online;
|
||||||
|
|
||||||
public readonly string Name;
|
public readonly string Name;
|
||||||
public readonly string RemoteName;
|
public readonly string RemoteName;
|
||||||
|
@ -58,49 +59,49 @@ namespace SparkleLib {
|
||||||
|
|
||||||
public string CurrentHash {
|
public string CurrentHash {
|
||||||
get {
|
get {
|
||||||
return _CurrentHash;
|
return this.current_hash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsBuffering {
|
public bool IsBuffering {
|
||||||
get {
|
get {
|
||||||
return _IsBuffering;
|
return this.is_buffering;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsPushing {
|
public bool IsPushing {
|
||||||
get {
|
get {
|
||||||
return _IsPushing;
|
return this.is_pushing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsPolling {
|
public bool IsPolling {
|
||||||
get {
|
get {
|
||||||
return _IsPolling;
|
return this.is_polling;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsSyncing {
|
public bool IsSyncing {
|
||||||
get {
|
get {
|
||||||
return _IsSyncing;
|
return this.is_syncing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsFetching {
|
public bool IsFetching {
|
||||||
get {
|
get {
|
||||||
return _IsFetching;
|
return this.is_fetching;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasUnsyncedChanges {
|
public bool HasUnsyncedChanges {
|
||||||
get {
|
get {
|
||||||
return _HasUnsyncedChanges;
|
return this.has_unsynced_changes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ServerOnline {
|
public bool ServerOnline {
|
||||||
get {
|
get {
|
||||||
return _ServerOnline;
|
return this.server_online;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,153 +142,154 @@ namespace SparkleLib {
|
||||||
Description = GetDescription ();
|
Description = GetDescription ();
|
||||||
UserName = GetUserName ();
|
UserName = GetUserName ();
|
||||||
UserEmail = GetUserEmail ();
|
UserEmail = GetUserEmail ();
|
||||||
_IsSyncing = false;
|
|
||||||
_IsBuffering = false;
|
this.is_syncing = false;
|
||||||
_IsPolling = true;
|
this.is_buffering = false;
|
||||||
_IsFetching = false;
|
this.is_polling = true;
|
||||||
_IsPushing = false;
|
this.is_fetching = false;
|
||||||
_ServerOnline = true;
|
this.is_pushing = false;
|
||||||
HasChanged = false;
|
this.server_online = true;
|
||||||
ChangeLock = new Object ();
|
this.has_changed = false;
|
||||||
FetchQueue = 0;
|
this.change_lock = new Object ();
|
||||||
AnnounceQueue = 0;
|
this.fetch_queue = 0;
|
||||||
|
this.announce_queue = 0;
|
||||||
|
|
||||||
if (IsEmpty)
|
if (IsEmpty)
|
||||||
_CurrentHash = null;
|
this.current_hash = null;
|
||||||
else
|
else
|
||||||
_CurrentHash = GetCurrentHash ();
|
this.current_hash = GetCurrentHash ();
|
||||||
|
|
||||||
string unsynced_file_path = SparkleHelpers.CombineMore (LocalPath,
|
string unsynced_file_path = SparkleHelpers.CombineMore (LocalPath,
|
||||||
".git", "has_unsynced_changes");
|
".git", "has_unsynced_changes");
|
||||||
|
|
||||||
if (File.Exists (unsynced_file_path))
|
if (File.Exists (unsynced_file_path))
|
||||||
_HasUnsyncedChanges = true;
|
this.has_unsynced_changes = true;
|
||||||
else
|
else
|
||||||
_HasUnsyncedChanges = false;
|
this.has_unsynced_changes = false;
|
||||||
|
|
||||||
if (_CurrentHash == null)
|
if (this.current_hash == null)
|
||||||
CreateInitialCommit ();
|
CreateInitialCommit ();
|
||||||
|
|
||||||
// Watch the repository's folder
|
// Watch the repository's folder
|
||||||
Watcher = new FileSystemWatcher (LocalPath) {
|
this.watcher = new FileSystemWatcher (LocalPath) {
|
||||||
IncludeSubdirectories = true,
|
IncludeSubdirectories = true,
|
||||||
EnableRaisingEvents = true,
|
EnableRaisingEvents = true,
|
||||||
Filter = "*"
|
Filter = "*"
|
||||||
};
|
};
|
||||||
|
|
||||||
Watcher.Changed += new FileSystemEventHandler (OnFileActivity);
|
this.watcher.Changed += new FileSystemEventHandler (OnFileActivity);
|
||||||
Watcher.Created += new FileSystemEventHandler (OnFileActivity);
|
this.watcher.Created += new FileSystemEventHandler (OnFileActivity);
|
||||||
Watcher.Deleted += new FileSystemEventHandler (OnFileActivity);
|
this.watcher.Deleted += new FileSystemEventHandler (OnFileActivity);
|
||||||
Watcher.Renamed += new RenamedEventHandler (OnFileActivity);
|
this.watcher.Renamed += new RenamedEventHandler (OnFileActivity);
|
||||||
|
|
||||||
// Listen to the irc channel on the server...
|
// Listen to the irc channel on the server...
|
||||||
if (UsesNotificationCenter)
|
if (UsesNotificationCenter)
|
||||||
Listener = new SparkleListener (Domain, RemoteName, UserEmail, NotificationServerType.Central);
|
this.listener = new SparkleListener (Domain, RemoteName, UserEmail, NotificationServerType.Central);
|
||||||
else
|
else
|
||||||
Listener = new SparkleListener (Domain, RemoteName, UserEmail, NotificationServerType.Own);
|
this.listener = new SparkleListener (Domain, RemoteName, UserEmail, NotificationServerType.Own);
|
||||||
|
|
||||||
// ...fetch remote changes every 60 seconds if that fails
|
// ...fetch remote changes every 60 seconds if that fails
|
||||||
RemoteTimer = new Timer () {
|
this.remote_timer = new Timer () {
|
||||||
Interval = 60000
|
Interval = 60000
|
||||||
};
|
};
|
||||||
|
|
||||||
RemoteTimer.Elapsed += delegate {
|
this.remote_timer.Elapsed += delegate {
|
||||||
if (_IsPolling) {
|
if (this.is_polling) {
|
||||||
CheckForRemoteChanges ();
|
CheckForRemoteChanges ();
|
||||||
|
|
||||||
if (!Listener.Client.IsConnected) {
|
if (!this.listener.Client.IsConnected) {
|
||||||
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Trying to reconnect...");
|
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Trying to reconnect...");
|
||||||
Listener.Listen ();
|
this.listener.Listen ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_HasUnsyncedChanges)
|
if (this.has_unsynced_changes)
|
||||||
FetchRebaseAndPush ();
|
FetchRebaseAndPush ();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Stop polling when the connection to the irc channel is succesful
|
// Stop polling when the connection to the irc channel is succesful
|
||||||
Listener.Client.OnConnected += delegate {
|
this.listener.Client.OnConnected += delegate {
|
||||||
_IsPolling = false;
|
this.is_polling = false;
|
||||||
|
|
||||||
// Check for changes manually one more time
|
// Check for changes manually one more time
|
||||||
CheckForRemoteChanges ();
|
CheckForRemoteChanges ();
|
||||||
|
|
||||||
// Push changes that were made since the last disconnect
|
// Push changes that were made since the last disconnect
|
||||||
if (_HasUnsyncedChanges)
|
if (this.has_unsynced_changes)
|
||||||
Push ();
|
Push ();
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Connected. Now listening... (" + Listener.Server + ")");
|
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Connected. Now listening... (" + this.listener.Server + ")");
|
||||||
|
|
||||||
if (AnnounceQueue > 0) {
|
if (this.announce_queue > 0) {
|
||||||
Listener.Announce (_CurrentHash);
|
this.listener.Announce (this.current_hash);
|
||||||
AnnounceQueue = 0;
|
this.announce_queue = 0;
|
||||||
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Queued messages delivered. (" + Listener.Server + ")");
|
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Queued messages delivered. (" + this.listener.Server + ")");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Start polling when the connection to the irc channel is lost
|
// Start polling when the connection to the irc channel is lost
|
||||||
Listener.Client.OnConnectionError += delegate {
|
this.listener.Client.OnConnectionError += delegate {
|
||||||
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Lost connection. Falling back to polling...");
|
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Lost connection. Falling back to polling...");
|
||||||
_IsPolling = true;
|
this.is_polling = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Start polling when the connection to the irc channel is lost
|
// Start polling when the connection to the irc channel is lost
|
||||||
Listener.Client.OnDisconnected += delegate {
|
this.listener.Client.OnDisconnected += delegate {
|
||||||
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Lost connection. Falling back to polling...");
|
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Lost connection. Falling back to polling...");
|
||||||
_IsPolling = true;
|
this.is_polling = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Fetch changes when there is a message in the irc channel
|
// Fetch changes when there is a message in the irc channel
|
||||||
Listener.Client.OnChannelMessage += delegate (object o, IrcEventArgs args) {
|
this.listener.Client.OnChannelMessage += delegate (object o, IrcEventArgs args) {
|
||||||
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Was notified of a remote change...");
|
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Was notified of a remote change...");
|
||||||
string message = args.Data.Message.Trim ();
|
string message = args.Data.Message.Trim ();
|
||||||
|
|
||||||
if (!message.Equals (_CurrentHash) && message.Length == 40) {
|
if (!message.Equals (this.current_hash) && message.Length == 40) {
|
||||||
FetchQueue++;
|
this.fetch_queue++;
|
||||||
|
|
||||||
if (_IsBuffering) {
|
if (this.is_buffering) {
|
||||||
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] ...but we're busy adding files. We'll fetch them later.");
|
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] ...but we're busy adding files. We'll fetch them later.");
|
||||||
} else if (!_IsFetching) {
|
} else if (!this.is_fetching) {
|
||||||
while (FetchQueue > 0) {
|
while (this.fetch_queue > 0) {
|
||||||
Fetch ();
|
Fetch ();
|
||||||
FetchQueue--;
|
this.fetch_queue--;
|
||||||
}
|
}
|
||||||
|
|
||||||
Watcher.EnableRaisingEvents = false;
|
this.watcher.EnableRaisingEvents = false;
|
||||||
Rebase ();
|
Rebase ();
|
||||||
Watcher.EnableRaisingEvents = true;
|
this.watcher.EnableRaisingEvents = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Not really needed as we won't be notified about our own messages
|
// Not really needed as we won't be notified about our own messages
|
||||||
SparkleHelpers.DebugInfo ("Irc",
|
SparkleHelpers.DebugInfo ("Irc",
|
||||||
"[" + Name + "] False alarm, already up to date. (" + _CurrentHash + ")");
|
"[" + Name + "] False alarm, already up to date. (" + this.current_hash + ")");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Start listening
|
// Start listening
|
||||||
Listener.Listen ();
|
this.listener.Listen ();
|
||||||
|
|
||||||
SizeBuffer = new List <double> ();
|
this.sizebuffer = new List <double> ();
|
||||||
|
|
||||||
// Keep a timer that checks if there are changes and
|
// Keep a timer that checks if there are changes and
|
||||||
// whether they have settled
|
// whether they have settled
|
||||||
LocalTimer = new Timer () {
|
this.local_timer = new Timer () {
|
||||||
Interval = 250
|
Interval = 250
|
||||||
};
|
};
|
||||||
|
|
||||||
LocalTimer.Elapsed += delegate (object o, ElapsedEventArgs args) {
|
this.local_timer.Elapsed += delegate (object o, ElapsedEventArgs args) {
|
||||||
CheckForChanges ();
|
CheckForChanges ();
|
||||||
};
|
};
|
||||||
|
|
||||||
RemoteTimer.Start ();
|
this.remote_timer.Start ();
|
||||||
LocalTimer.Start ();
|
this.local_timer.Start ();
|
||||||
|
|
||||||
// Add everything that changed
|
// Add everything that changed
|
||||||
// since SparkleShare was stopped
|
// since SparkleShare was stopped
|
||||||
AddCommitAndPush ();
|
AddCommitAndPush ();
|
||||||
|
|
||||||
if (_CurrentHash == null)
|
if (this.current_hash == null)
|
||||||
_CurrentHash = GetCurrentHash ();
|
this.current_hash = GetCurrentHash ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -302,13 +304,13 @@ namespace SparkleLib {
|
||||||
|
|
||||||
string remote_hash = git.StandardOutput.ReadToEnd ();
|
string remote_hash = git.StandardOutput.ReadToEnd ();
|
||||||
|
|
||||||
if (!remote_hash.StartsWith (_CurrentHash)) {
|
if (!remote_hash.StartsWith (this.current_hash)) {
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Remote changes found. (" + remote_hash + ")");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Remote changes found. (" + remote_hash + ")");
|
||||||
Fetch ();
|
Fetch ();
|
||||||
|
|
||||||
Watcher.EnableRaisingEvents = false;
|
this.watcher.EnableRaisingEvents = false;
|
||||||
Rebase ();
|
Rebase ();
|
||||||
Watcher.EnableRaisingEvents = true;
|
this.watcher.EnableRaisingEvents = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -319,26 +321,26 @@ namespace SparkleLib {
|
||||||
|
|
||||||
private void CheckForChanges ()
|
private void CheckForChanges ()
|
||||||
{
|
{
|
||||||
lock (ChangeLock) {
|
lock (this.change_lock) {
|
||||||
if (HasChanged) {
|
if (this.has_changed) {
|
||||||
if (SizeBuffer.Count >= 4)
|
if ( this.sizebuffer.Count >= 4)
|
||||||
SizeBuffer.RemoveAt (0);
|
this.sizebuffer.RemoveAt (0);
|
||||||
|
|
||||||
DirectoryInfo dir_info = new DirectoryInfo (LocalPath);
|
DirectoryInfo dir_info = new DirectoryInfo (LocalPath);
|
||||||
SizeBuffer.Add (CalculateFolderSize (dir_info));
|
this.sizebuffer.Add (CalculateFolderSize (dir_info));
|
||||||
|
|
||||||
if (SizeBuffer [0].Equals (SizeBuffer [1]) &&
|
if ( this.sizebuffer [0].Equals ( this.sizebuffer [1]) &&
|
||||||
SizeBuffer [1].Equals (SizeBuffer [2]) &&
|
this.sizebuffer [1].Equals ( this.sizebuffer [2]) &&
|
||||||
SizeBuffer [2].Equals (SizeBuffer [3])) {
|
this.sizebuffer [2].Equals ( this.sizebuffer [3])) {
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Local", "[" + Name + "] Changes have settled.");
|
SparkleHelpers.DebugInfo ("Local", "[" + Name + "] Changes have settled.");
|
||||||
_IsBuffering = false;
|
this.is_buffering = false;
|
||||||
HasChanged = false;
|
this.has_changed = false;
|
||||||
|
|
||||||
while (AnyDifferences) {
|
while (AnyDifferences) {
|
||||||
Watcher.EnableRaisingEvents = false;
|
this.watcher.EnableRaisingEvents = false;
|
||||||
AddCommitAndPush ();
|
AddCommitAndPush ();
|
||||||
Watcher.EnableRaisingEvents = true;
|
this.watcher.EnableRaisingEvents = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -355,11 +357,11 @@ namespace SparkleLib {
|
||||||
WatcherChangeTypes wct = fse_args.ChangeType;
|
WatcherChangeTypes wct = fse_args.ChangeType;
|
||||||
|
|
||||||
if (AnyDifferences) {
|
if (AnyDifferences) {
|
||||||
_IsBuffering = true;
|
this.is_buffering = true;
|
||||||
|
|
||||||
// Only fire the event if the timer has been stopped.
|
// Only fire the event if the timer has been stopped.
|
||||||
// This prevents multiple events from being raised whilst "buffering".
|
// This prevents multiple events from being raised whilst "buffering".
|
||||||
if (!HasChanged) {
|
if (!this.has_changed) {
|
||||||
SparkleEventArgs args = new SparkleEventArgs ("ChangesDetected");
|
SparkleEventArgs args = new SparkleEventArgs ("ChangesDetected");
|
||||||
|
|
||||||
if (ChangesDetected != null)
|
if (ChangesDetected != null)
|
||||||
|
@ -369,10 +371,10 @@ namespace SparkleLib {
|
||||||
SparkleHelpers.DebugInfo ("Event", "[" + Name + "] " + wct.ToString () + " '" + fse_args.Name + "'");
|
SparkleHelpers.DebugInfo ("Event", "[" + Name + "] " + wct.ToString () + " '" + fse_args.Name + "'");
|
||||||
SparkleHelpers.DebugInfo ("Local", "[" + Name + "] Changes found, checking if settled.");
|
SparkleHelpers.DebugInfo ("Local", "[" + Name + "] Changes found, checking if settled.");
|
||||||
|
|
||||||
RemoteTimer.Stop ();
|
this.remote_timer.Stop ();
|
||||||
|
|
||||||
lock (ChangeLock) {
|
lock (this.change_lock) {
|
||||||
HasChanged = true;
|
this.has_changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -383,8 +385,8 @@ namespace SparkleLib {
|
||||||
public void AddCommitAndPush ()
|
public void AddCommitAndPush ()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
LocalTimer.Stop ();
|
this.local_timer.Stop ();
|
||||||
RemoteTimer.Stop ();
|
this.remote_timer.Stop ();
|
||||||
|
|
||||||
if (AnyDifferences) {
|
if (AnyDifferences) {
|
||||||
Add ();
|
Add ();
|
||||||
|
@ -400,8 +402,8 @@ namespace SparkleLib {
|
||||||
CommitEndedUpEmpty (this, args);
|
CommitEndedUpEmpty (this, args);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
RemoteTimer.Start ();
|
this.remote_timer.Start ();
|
||||||
LocalTimer.Start ();
|
this.local_timer.Start ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,8 +504,8 @@ namespace SparkleLib {
|
||||||
git.Start ();
|
git.Start ();
|
||||||
git.WaitForExit ();
|
git.WaitForExit ();
|
||||||
|
|
||||||
_CurrentHash = GetCurrentHash ();
|
this.current_hash = GetCurrentHash ();
|
||||||
SparkleHelpers.DebugInfo ("Commit", "[" + Name + "] " + message + " (" + _CurrentHash + ")");
|
SparkleHelpers.DebugInfo ("Commit", "[" + Name + "] " + message + " (" + this.current_hash + ")");
|
||||||
|
|
||||||
SparkleEventArgs args = new SparkleEventArgs ("Commited") {
|
SparkleEventArgs args = new SparkleEventArgs ("Commited") {
|
||||||
Message = message
|
Message = message
|
||||||
|
@ -521,10 +523,10 @@ namespace SparkleLib {
|
||||||
// Fetches changes from the remote repository
|
// Fetches changes from the remote repository
|
||||||
public void Fetch ()
|
public void Fetch ()
|
||||||
{
|
{
|
||||||
_IsSyncing = true;
|
this.is_syncing = true;
|
||||||
_IsFetching = true;
|
this.is_fetching = true;
|
||||||
|
|
||||||
RemoteTimer.Stop ();
|
this.remote_timer.Stop ();
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Fetching changes...");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Fetching changes...");
|
||||||
SparkleGit git = new SparkleGit (LocalPath, "fetch -v origin master");
|
SparkleGit git = new SparkleGit (LocalPath, "fetch -v origin master");
|
||||||
|
@ -537,19 +539,19 @@ namespace SparkleLib {
|
||||||
git.Exited += delegate {
|
git.Exited += delegate {
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes fetched.");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes fetched.");
|
||||||
|
|
||||||
_IsSyncing = false;
|
this.is_syncing = false;
|
||||||
_IsFetching = false;
|
this.is_fetching = false;
|
||||||
_CurrentHash = GetCurrentHash ();
|
this.current_hash = GetCurrentHash ();
|
||||||
|
|
||||||
if (git.ExitCode != 0) {
|
if (git.ExitCode != 0) {
|
||||||
_ServerOnline = false;
|
this.server_online = false;
|
||||||
|
|
||||||
args = new SparkleEventArgs ("FetchingFailed");
|
args = new SparkleEventArgs ("FetchingFailed");
|
||||||
|
|
||||||
if (FetchingFailed != null)
|
if (FetchingFailed != null)
|
||||||
FetchingFailed (this, args);
|
FetchingFailed (this, args);
|
||||||
} else {
|
} else {
|
||||||
_ServerOnline = true;
|
this.server_online = true;
|
||||||
|
|
||||||
args = new SparkleEventArgs ("FetchingFinished");
|
args = new SparkleEventArgs ("FetchingFinished");
|
||||||
|
|
||||||
|
@ -557,7 +559,7 @@ namespace SparkleLib {
|
||||||
FetchingFinished (this, args);
|
FetchingFinished (this, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoteTimer.Start ();
|
this.remote_timer.Start ();
|
||||||
};
|
};
|
||||||
|
|
||||||
git.Start ();
|
git.Start ();
|
||||||
|
@ -581,26 +583,26 @@ namespace SparkleLib {
|
||||||
git.Exited += delegate {
|
git.Exited += delegate {
|
||||||
if (git.ExitCode != 0) {
|
if (git.ExitCode != 0) {
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict detected. Trying to get out...");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict detected. Trying to get out...");
|
||||||
Watcher.EnableRaisingEvents = false;
|
this.watcher.EnableRaisingEvents = false;
|
||||||
|
|
||||||
while (AnyDifferences)
|
while (AnyDifferences)
|
||||||
ResolveConflict ();
|
ResolveConflict ();
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict resolved.");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict resolved.");
|
||||||
Watcher.EnableRaisingEvents = true;
|
this.watcher.EnableRaisingEvents = true;
|
||||||
|
|
||||||
SparkleEventArgs args = new SparkleEventArgs ("ConflictDetected");
|
SparkleEventArgs args = new SparkleEventArgs ("ConflictDetected");
|
||||||
if (ConflictDetected != null)
|
if (ConflictDetected != null)
|
||||||
ConflictDetected (this, args);
|
ConflictDetected (this, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
_CurrentHash = GetCurrentHash ();
|
this.current_hash = GetCurrentHash ();
|
||||||
};
|
};
|
||||||
|
|
||||||
git.Start ();
|
git.Start ();
|
||||||
git.WaitForExit ();
|
git.WaitForExit ();
|
||||||
|
|
||||||
_CurrentHash = GetCurrentHash ();
|
this.current_hash = GetCurrentHash ();
|
||||||
|
|
||||||
if (NewCommit != null)
|
if (NewCommit != null)
|
||||||
NewCommit (GetCommits (1) [0], LocalPath);
|
NewCommit (GetCommits (1) [0], LocalPath);
|
||||||
|
@ -707,8 +709,8 @@ namespace SparkleLib {
|
||||||
// Pushes the changes to the remote repo
|
// Pushes the changes to the remote repo
|
||||||
public void Push ()
|
public void Push ()
|
||||||
{
|
{
|
||||||
_IsSyncing = true;
|
this.is_syncing = true;
|
||||||
_IsPushing = true;
|
this.is_pushing = true;
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Pushing changes...");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Pushing changes...");
|
||||||
SparkleGit git = new SparkleGit (LocalPath, "push origin master");
|
SparkleGit git = new SparkleGit (LocalPath, "push origin master");
|
||||||
|
@ -719,8 +721,8 @@ namespace SparkleLib {
|
||||||
PushingStarted (this, args);
|
PushingStarted (this, args);
|
||||||
|
|
||||||
git.Exited += delegate {
|
git.Exited += delegate {
|
||||||
_IsSyncing = false;
|
this.is_syncing = false;
|
||||||
_IsPushing = false;
|
this.is_pushing = false;
|
||||||
|
|
||||||
if (git.ExitCode != 0) {
|
if (git.ExitCode != 0) {
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Pushing failed.");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Pushing failed.");
|
||||||
|
@ -731,7 +733,7 @@ namespace SparkleLib {
|
||||||
if (!File.Exists (unsynced_file_path))
|
if (!File.Exists (unsynced_file_path))
|
||||||
File.Create (unsynced_file_path);
|
File.Create (unsynced_file_path);
|
||||||
|
|
||||||
_HasUnsyncedChanges = true;
|
this.has_unsynced_changes = true;
|
||||||
|
|
||||||
args = new SparkleEventArgs ("PushingFailed");
|
args = new SparkleEventArgs ("PushingFailed");
|
||||||
|
|
||||||
|
@ -749,15 +751,15 @@ namespace SparkleLib {
|
||||||
if (File.Exists (unsynced_file_path))
|
if (File.Exists (unsynced_file_path))
|
||||||
File.Delete (unsynced_file_path);
|
File.Delete (unsynced_file_path);
|
||||||
|
|
||||||
_HasUnsyncedChanges = false;
|
this.has_unsynced_changes = false;
|
||||||
|
|
||||||
if (PushingFinished != null)
|
if (PushingFinished != null)
|
||||||
PushingFinished (this, args);
|
PushingFinished (this, args);
|
||||||
|
|
||||||
if (Listener.Client.IsConnected) {
|
if (this.listener.Client.IsConnected) {
|
||||||
Listener.Announce (_CurrentHash);
|
this.listener.Announce (this.current_hash);
|
||||||
} else {
|
} else {
|
||||||
AnnounceQueue++;
|
this.announce_queue++;
|
||||||
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Could not deliver notification, added it to the queue");
|
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Could not deliver notification, added it to the queue");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1079,9 +1081,9 @@ namespace SparkleLib {
|
||||||
// Disposes all resourses of this object
|
// Disposes all resourses of this object
|
||||||
public void Dispose ()
|
public void Dispose ()
|
||||||
{
|
{
|
||||||
RemoteTimer.Dispose ();
|
this.remote_timer.Dispose ();
|
||||||
LocalTimer.Dispose ();
|
this.local_timer.Dispose ();
|
||||||
Listener.Dispose ();
|
this.listener.Dispose ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue