diff --git a/SparkleLib/SparkleRepoBase.cs b/SparkleLib/SparkleRepoBase.cs index 8fc39214..3e7b1eb5 100755 --- a/SparkleLib/SparkleRepoBase.cs +++ b/SparkleLib/SparkleRepoBase.cs @@ -36,6 +36,8 @@ namespace SparkleLib { public abstract class SparkleRepoBase { + public static bool UseCustomWatcher = false; + public abstract string CurrentRevision { get; } public abstract double Size { get; } public abstract double HistorySize { get; } @@ -149,7 +151,9 @@ namespace SparkleLib { Status = status; }; - this.watcher = new SparkleWatcher (LocalPath); + if (!UseCustomWatcher) + this.watcher = new SparkleWatcher (LocalPath); + new Thread (() => CreateListener ()).Start (); this.remote_timer.Elapsed += delegate { @@ -176,7 +180,8 @@ namespace SparkleLib { public void Initialize () { - this.watcher.ChangeEvent += OnFileActivity; + if (!UseCustomWatcher) + this.watcher.ChangeEvent += OnFileActivity; // Sync up everything that changed // since we've been offline @@ -213,7 +218,9 @@ namespace SparkleLib { return; IsBuffering = true; - this.watcher.Disable (); + + if (!UseCustomWatcher) + this.watcher.Disable (); SparkleLogger.LogInfo ("Local", Name + " | Activity detected, waiting for it to settle..."); @@ -250,7 +257,8 @@ namespace SparkleLib { } while (IsBuffering); - this.watcher.Enable (); + if (!UseCustomWatcher) + this.watcher.Enable (); } @@ -279,7 +287,8 @@ namespace SparkleLib { private void SyncUpBase () { - this.watcher.Disable (); + if (!UseCustomWatcher) + this.watcher.Disable (); SparkleLogger.LogInfo ("SyncUp", Name + " | Initiated"); HasUnsyncedChanges = true; @@ -299,7 +308,8 @@ namespace SparkleLib { SparkleLogger.LogInfo ("SyncUp", Name + " | Error"); SyncDownBase (); - this.watcher.Disable (); + if (!UseCustomWatcher) + this.watcher.Disable (); if (ServerOnline && SyncUp ()) { HasUnsyncedChanges = false; @@ -316,13 +326,15 @@ namespace SparkleLib { ProgressPercentage = 0.0; ProgressSpeed = ""; - this.watcher.Enable (); + if (!UseCustomWatcher) + this.watcher.Enable (); } private void SyncDownBase () { - this.watcher.Disable (); + if (!UseCustomWatcher) + this.watcher.Disable (); SparkleLogger.LogInfo ("SyncDown", Name + " | Initiated"); @@ -373,7 +385,8 @@ namespace SparkleLib { ProgressPercentage = 0.0; ProgressSpeed = ""; - this.watcher.Enable (); + if (!UseCustomWatcher) + this.watcher.Enable (); SyncStatusChanged (SyncStatus.Idle); } @@ -489,7 +502,8 @@ namespace SparkleLib { this.listener.Disconnected -= ListenerDisconnectedDelegate; this.listener.AnnouncementReceived -= ListenerAnnouncementReceivedDelegate; - this.watcher.Dispose (); + if (!UseCustomWatcher) + this.watcher.Dispose (); } } } diff --git a/SparkleShare/Mac/SparkleController.cs b/SparkleShare/Mac/SparkleController.cs index f70bd962..577b9b2d 100755 --- a/SparkleShare/Mac/SparkleController.cs +++ b/SparkleShare/Mac/SparkleController.cs @@ -18,6 +18,7 @@ using System; using System.Diagnostics; using System.IO; +using System.Threading; using MonoMac.Foundation; using MonoMac.AppKit; @@ -68,8 +69,9 @@ namespace SparkleShare { { base.Initialize (); + SparkleRepoBase.UseCustomWatcher = true; + this.watcher.Changed += delegate (string path) { - // Don't even bother with paths in .git/ if (path.Contains (".git")) return; @@ -80,18 +82,16 @@ namespace SparkleShare { else repo_name = path; - // Ignore changes in the root of each subfolder, these - // are already handled by the repository - if (Path.GetFileNameWithoutExtension (path).Equals (repo_name)) - return; - repo_name = repo_name.Trim ("/".ToCharArray ()); FileSystemEventArgs fse_args = new FileSystemEventArgs (WatcherChangeTypes.Changed, Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, path), Path.GetFileName (path)); foreach (SparkleRepoBase repo in Repositories) { - if (repo.Name.Equals (repo_name)) - repo.OnFileActivity (fse_args); + if (repo.Name.Equals (repo_name)) { + new Thread (() => { + repo.OnFileActivity (fse_args); + }).Start (); + } } }; }