Merge remote branch 'upstream/master' into autofoo
This commit is contained in:
commit
740d3c0af7
|
@ -172,11 +172,11 @@ namespace SparkleShare {
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + RepoName + "] Repository cloned");
|
SparkleHelpers.DebugInfo ("Git", "[" + RepoName + "] Repository cloned");
|
||||||
SparkleShare.SparkleUI.UpdateRepositories ();
|
|
||||||
|
|
||||||
Directory.Move (SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath, RepoName),
|
Directory.Move (SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath, RepoName),
|
||||||
SparkleHelpers.CombineMore (SparklePaths.SparklePath, RepoName));
|
SparkleHelpers.CombineMore (SparklePaths.SparklePath, RepoName));
|
||||||
|
|
||||||
|
|
||||||
// Add a .gitignore file to the repo
|
// Add a .gitignore file to the repo
|
||||||
TextWriter Writer = new StreamWriter (SparkleHelpers.CombineMore (SparklePaths.SparklePath, RepoName,
|
TextWriter Writer = new StreamWriter (SparkleHelpers.CombineMore (SparklePaths.SparklePath, RepoName,
|
||||||
".gitignore"));
|
".gitignore"));
|
||||||
|
@ -184,6 +184,8 @@ namespace SparkleShare {
|
||||||
Writer.WriteLine (".*.sw?"); // Ignore vi swap files
|
Writer.WriteLine (".*.sw?"); // Ignore vi swap files
|
||||||
Writer.Close ();
|
Writer.Close ();
|
||||||
|
|
||||||
|
SparkleShare.SparkleUI.UpdateRepositories ();
|
||||||
|
|
||||||
// Show a confirmation notification
|
// Show a confirmation notification
|
||||||
SparkleBubble FinishedBubble;
|
SparkleBubble FinishedBubble;
|
||||||
FinishedBubble = new SparkleBubble (String.Format(_("Successfully synced folder ‘{0}’"), RepoName),
|
FinishedBubble = new SparkleBubble (String.Format(_("Successfully synced folder ‘{0}’"), RepoName),
|
||||||
|
|
|
@ -33,6 +33,8 @@ namespace SparkleShare {
|
||||||
private Timer FetchTimer;
|
private Timer FetchTimer;
|
||||||
private Timer BufferTimer;
|
private Timer BufferTimer;
|
||||||
private FileSystemWatcher Watcher;
|
private FileSystemWatcher Watcher;
|
||||||
|
private bool HasChanged = false;
|
||||||
|
private DateTime LastChange;
|
||||||
|
|
||||||
public string Name;
|
public string Name;
|
||||||
public string Domain;
|
public string Domain;
|
||||||
|
@ -118,28 +120,30 @@ namespace SparkleShare {
|
||||||
};
|
};
|
||||||
|
|
||||||
FetchTimer.Start ();
|
FetchTimer.Start ();
|
||||||
BufferTimer = new Timer ();
|
|
||||||
|
|
||||||
|
BufferTimer = new Timer ();
|
||||||
|
BufferTimer.Interval = 4000;
|
||||||
BufferTimer.Elapsed += delegate (object o, ElapsedEventArgs args) {
|
BufferTimer.Elapsed += delegate (object o, ElapsedEventArgs args) {
|
||||||
SparkleHelpers.DebugInfo ("Buffer", "[" + Name + "] Done waiting.");
|
SparkleHelpers.DebugInfo ("Buffer", "[" + Name + "] Checking for changes.");
|
||||||
Add ();
|
|
||||||
string Message = FormatCommitMessage ();
|
if (HasChanged) {
|
||||||
if (!Message.Equals ("")) {
|
SparkleHelpers.DebugInfo ("Buffer", "[" + Name + "] Changes found, checking if settled.");
|
||||||
Commit (Message);
|
DateTime now = DateTime.UtcNow;
|
||||||
Fetch ();
|
TimeSpan changed = new TimeSpan (now.Ticks - LastChange.Ticks);
|
||||||
Push ();
|
if (changed.TotalMilliseconds > 5000) {
|
||||||
|
HasChanged = false;
|
||||||
|
SparkleHelpers.DebugInfo ("Buffer", "[" + Name + "] Changes have settled, adding.");
|
||||||
|
AddCommitAndPush ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BufferTimer.Start ();
|
||||||
|
|
||||||
// Add everything that changed
|
// Add everything that changed
|
||||||
// since SparkleShare was stopped
|
// since SparkleShare was stopped
|
||||||
Add ();
|
|
||||||
string commit_message = FormatCommitMessage ();
|
AddCommitAndPush ();
|
||||||
if (!commit_message.Equals ("")) {
|
|
||||||
Commit (commit_message);
|
|
||||||
Fetch ();
|
|
||||||
Push ();
|
|
||||||
}
|
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Nothing going on...");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Nothing going on...");
|
||||||
|
|
||||||
|
@ -151,48 +155,34 @@ namespace SparkleShare {
|
||||||
WatcherChangeTypes wct = args.ChangeType;
|
WatcherChangeTypes wct = args.ChangeType;
|
||||||
if (!ShouldIgnore (args.Name)) {
|
if (!ShouldIgnore (args.Name)) {
|
||||||
SparkleHelpers.DebugInfo ("Event", "[" + Name + "] " + wct.ToString () + " '" + args.Name + "'");
|
SparkleHelpers.DebugInfo ("Event", "[" + Name + "] " + wct.ToString () + " '" + args.Name + "'");
|
||||||
StartBufferTimer ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// A buffer that will fetch changes after
|
|
||||||
// file activity has settles down
|
|
||||||
private void StartBufferTimer ()
|
|
||||||
{
|
|
||||||
|
|
||||||
FetchTimer.Stop ();
|
FetchTimer.Stop ();
|
||||||
int Interval = 4000;
|
LastChange = DateTime.UtcNow;
|
||||||
if (!BufferTimer.Enabled) {
|
HasChanged = true;
|
||||||
|
}
|
||||||
// Delay for a few seconds to see if more files change
|
|
||||||
BufferTimer.Interval = Interval;
|
|
||||||
BufferTimer.Elapsed += delegate (object o, ElapsedEventArgs args) {
|
|
||||||
SparkleHelpers.DebugInfo ("Buffer", "[" + Name + "] Done waiting.");
|
|
||||||
Add ();
|
|
||||||
};
|
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Buffer", "[" + Name + "] " + "Waiting for more changes...");
|
|
||||||
BufferTimer.Start ();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// Extend the delay when something changes
|
|
||||||
BufferTimer.Close ();
|
|
||||||
BufferTimer = new Timer ();
|
|
||||||
BufferTimer.Interval = Interval;
|
|
||||||
|
|
||||||
FetchTimer.Start ();
|
|
||||||
|
|
||||||
BufferTimer.Start ();
|
|
||||||
SparkleHelpers.DebugInfo ("Buffer", "[" + Name + "] " + "Waiting for more changes...");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
// When there are changes we generally want to Add, Commit and Push
|
||||||
|
// so this method does them all with appropriate timers, etc switched off
|
||||||
public void Add ()
|
public void AddCommitAndPush ()
|
||||||
{
|
{
|
||||||
BufferTimer.Stop ();
|
BufferTimer.Stop ();
|
||||||
FetchTimer.Stop ();
|
FetchTimer.Stop ();
|
||||||
|
|
||||||
|
Add ();
|
||||||
|
string Message = FormatCommitMessage ();
|
||||||
|
if (!Message.Equals ("")) {
|
||||||
|
Commit (Message);
|
||||||
|
Fetch ();
|
||||||
|
Push ();
|
||||||
|
}
|
||||||
|
|
||||||
|
FetchTimer.Start ();
|
||||||
|
BufferTimer.Start ();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stages the made changes
|
||||||
|
private void Add ()
|
||||||
|
{
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Staging changes...");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Staging changes...");
|
||||||
Process.StartInfo.Arguments = "add --all";
|
Process.StartInfo.Arguments = "add --all";
|
||||||
Process.Start ();
|
Process.Start ();
|
||||||
|
@ -200,7 +190,6 @@ namespace SparkleShare {
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes staged.");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes staged.");
|
||||||
// SparkleUI.NotificationIcon.SetSyncingState ();
|
// SparkleUI.NotificationIcon.SetSyncingState ();
|
||||||
// SparkleUI.NotificationIcon.SetIdleState ();
|
// SparkleUI.NotificationIcon.SetIdleState ();
|
||||||
FetchTimer.Start ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commits the made changes
|
// Commits the made changes
|
||||||
|
|
Loading…
Reference in a new issue