[repo] Add a simple notification queue when disconnected, and send them when reconnected.
This commit is contained in:
parent
e609c0b3a4
commit
7bcefc9831
|
@ -24,25 +24,19 @@ namespace SparkleLib {
|
||||||
|
|
||||||
public SparkleGit (string path, string args) : base ()
|
public SparkleGit (string path, string args) : base ()
|
||||||
{
|
{
|
||||||
|
|
||||||
EnableRaisingEvents = true;
|
EnableRaisingEvents = true;
|
||||||
StartInfo.FileName = SparklePaths.GitPath;
|
StartInfo.FileName = SparklePaths.GitPath;
|
||||||
StartInfo.Arguments = args;
|
StartInfo.Arguments = args;
|
||||||
StartInfo.RedirectStandardOutput = true;
|
StartInfo.RedirectStandardOutput = true;
|
||||||
StartInfo.UseShellExecute = false;
|
StartInfo.UseShellExecute = false;
|
||||||
StartInfo.WorkingDirectory = path;
|
StartInfo.WorkingDirectory = path;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
new public void Start ()
|
new public void Start ()
|
||||||
{
|
{
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Cmd", StartInfo.FileName + " " + StartInfo.Arguments);
|
SparkleHelpers.DebugInfo ("Cmd", StartInfo.FileName + " " + StartInfo.Arguments);
|
||||||
base.Start ();
|
base.Start ();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -33,7 +33,8 @@ namespace SparkleLib {
|
||||||
private Timer LocalTimer;
|
private Timer LocalTimer;
|
||||||
private FileSystemWatcher Watcher;
|
private FileSystemWatcher Watcher;
|
||||||
private System.Object ChangeLock;
|
private System.Object ChangeLock;
|
||||||
private int FetchRequests;
|
private int FetchQueue;
|
||||||
|
private int AnnounceQueue;
|
||||||
private SparkleListener Listener;
|
private SparkleListener Listener;
|
||||||
private List <double> SizeBuffer;
|
private List <double> SizeBuffer;
|
||||||
private bool HasChanged;
|
private bool HasChanged;
|
||||||
|
@ -134,22 +135,22 @@ namespace SparkleLib {
|
||||||
{
|
{
|
||||||
LocalPath = path;
|
LocalPath = path;
|
||||||
Name = Path.GetFileName (LocalPath);
|
Name = Path.GetFileName (LocalPath);
|
||||||
|
|
||||||
RemoteOriginUrl = GetRemoteOriginUrl ();
|
RemoteOriginUrl = GetRemoteOriginUrl ();
|
||||||
RemoteName = Path.GetFileNameWithoutExtension (RemoteOriginUrl);
|
RemoteName = Path.GetFileNameWithoutExtension (RemoteOriginUrl);
|
||||||
Domain = GetDomain (RemoteOriginUrl);
|
Domain = GetDomain (RemoteOriginUrl);
|
||||||
Description = GetDescription ();
|
Description = GetDescription ();
|
||||||
UserName = GetUserName ();
|
UserName = GetUserName ();
|
||||||
UserEmail = GetUserEmail ();
|
UserEmail = GetUserEmail ();
|
||||||
_IsSyncing = false;
|
_IsSyncing = false;
|
||||||
_IsBuffering = false;
|
_IsBuffering = false;
|
||||||
_IsPolling = true;
|
_IsPolling = true;
|
||||||
_IsFetching = false;
|
_IsFetching = false;
|
||||||
_IsPushing = false;
|
_IsPushing = false;
|
||||||
_ServerOnline = true;
|
_ServerOnline = true;
|
||||||
HasChanged = false;
|
HasChanged = false;
|
||||||
ChangeLock = new Object ();
|
ChangeLock = new Object ();
|
||||||
FetchRequests = 0;
|
FetchQueue = 0;
|
||||||
|
AnnounceQueue = 0;
|
||||||
|
|
||||||
if (IsEmpty)
|
if (IsEmpty)
|
||||||
_CurrentHash = null;
|
_CurrentHash = null;
|
||||||
|
@ -216,6 +217,12 @@ namespace SparkleLib {
|
||||||
Push ();
|
Push ();
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Connected. Now listening... (" + Listener.Server + ")");
|
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Connected. Now listening... (" + Listener.Server + ")");
|
||||||
|
|
||||||
|
if (AnnounceQueue > 0) {
|
||||||
|
Listener.Announce (_CurrentHash);
|
||||||
|
AnnounceQueue = 0;
|
||||||
|
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Queued messages delivered. (" + Listener.Server + ")");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Start polling when the connection to the irc channel is lost
|
// Start polling when the connection to the irc channel is lost
|
||||||
|
@ -236,12 +243,12 @@ namespace SparkleLib {
|
||||||
string message = args.Data.Message.Trim ();
|
string message = args.Data.Message.Trim ();
|
||||||
|
|
||||||
if (!message.Equals (_CurrentHash) && message.Length == 40) {
|
if (!message.Equals (_CurrentHash) && message.Length == 40) {
|
||||||
FetchRequests++;
|
FetchQueue++;
|
||||||
|
|
||||||
if (!_IsFetching) {
|
if (!_IsFetching) {
|
||||||
while (FetchRequests > 0) {
|
while (FetchQueue > 0) {
|
||||||
Fetch ();
|
Fetch ();
|
||||||
FetchRequests--;
|
FetchQueue--;
|
||||||
}
|
}
|
||||||
|
|
||||||
Watcher.EnableRaisingEvents = false;
|
Watcher.EnableRaisingEvents = false;
|
||||||
|
@ -666,8 +673,12 @@ namespace SparkleLib {
|
||||||
if (PushingFinished != null)
|
if (PushingFinished != null)
|
||||||
PushingFinished (this, args);
|
PushingFinished (this, args);
|
||||||
|
|
||||||
if (!_IsPolling)
|
if (Listener.Client.IsConnected) {
|
||||||
Listener.Announce (_CurrentHash);
|
Listener.Announce (_CurrentHash);
|
||||||
|
} else {
|
||||||
|
AnnounceQueue++;
|
||||||
|
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Could not deliver notification, added it to the queue");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue