From 1c156b5e5d03c59f38b81e442dce1f30132658df Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sat, 22 Sep 2012 23:09:36 +0100 Subject: [PATCH] repo: Make sure there is always only one buffer/sync thread on file activity. Closes #982 --- SparkleLib/SparkleRepoBase.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/SparkleLib/SparkleRepoBase.cs b/SparkleLib/SparkleRepoBase.cs index 5e92b3a0..e37ac9a1 100755 --- a/SparkleLib/SparkleRepoBase.cs +++ b/SparkleLib/SparkleRepoBase.cs @@ -209,23 +209,26 @@ namespace SparkleLib { } + private Object buffer_lock = new Object (); + public void OnFileActivity (FileSystemEventArgs args) { if (IsBuffering) return; - ChangesDetected (); - string relative_path = args.FullPath.Replace (LocalPath, ""); - foreach (string exclude_path in ExcludePaths) { - if (relative_path.Contains (exclude_path)) + if (args.FullPath.Contains (exclude_path)) return; } - if (IsBuffering || !HasLocalChanges) - return; + lock (this.buffer_lock) { + if (IsBuffering || !HasLocalChanges) + return; - IsBuffering = true; + IsBuffering = true; + } + + ChangesDetected (); if (!UseCustomWatcher) this.watcher.Disable ();