[tomboy] Tune down autosync frequency



commit 89f234fb08c8f95cb6b00f808a0f7e5896880fe0
Author: Aaron Borden <adborden live com>
Date:   Sat Aug 20 15:18:02 2011 -0700

    Tune down autosync frequency
    
    https://bugzilla.gnome.org/show_bug.cgi?id=632615

 Tomboy/Synchronization/SyncManager.cs |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/Tomboy/Synchronization/SyncManager.cs b/Tomboy/Synchronization/SyncManager.cs
index 832b34b..a175929 100644
--- a/Tomboy/Synchronization/SyncManager.cs
+++ b/Tomboy/Synchronization/SyncManager.cs
@@ -232,14 +232,19 @@ namespace Tomboy.Sync
 
 		static void HandleNoteBufferChanged (Note note)
 		{
-			// If note text changes, kill the timer.  It will
-			// automatically be resurrected once a Save occurs.
+			// Note changed, iff a sync is coming up we kill the
+			// timer to avoid interupting the user (we want to
+			// make sure not to sync more often than the user's pref)
 			if (syncThread == null && autosyncTimer != null) {
-				Logger.Debug ("Note edited...killing autosync timer until next save or delete event");
-				autosyncTimer.Dispose ();
-				autosyncTimer = null;
+				TimeSpan timeSinceLastCheck =
+					DateTime.Now - lastBackgroundCheck;
+				if (timeSinceLastCheck.TotalMinutes > autosyncTimeoutPrefMinutes - 1) {
+					Logger.Debug ("Note edited...killing autosync timer until next save or delete event");
+					autosyncTimer.Dispose ();
+					autosyncTimer = null;
+					NoteMgr.NoteBufferChanged -= HandleNoteBufferChanged;
+				}
 			}
-			NoteMgr.NoteBufferChanged -= HandleNoteBufferChanged;
 		}
 
 		static void Preferences_SettingChanged (object sender, EventArgs args)
@@ -271,8 +276,8 @@ namespace Tomboy.Sync
 					Logger.Debug ("Autosync pref changed...restarting sync timer");
 					autosyncTimeoutPrefMinutes = autosyncTimeoutPrefMinutes >= 5 ? autosyncTimeoutPrefMinutes : 5;
 					lastBackgroundCheck = DateTime.Now;
-					 // Perform a sync one minute after setting change
-					currentAutosyncTimeoutMinutes = 1;
+					 // Perform a sync no sooner than user specified
+					currentAutosyncTimeoutMinutes = autosyncTimeoutPrefMinutes;
 					autosyncTimer = new Timer ((o) => BackgroundSyncChecker (),
 					                           null,
 					                           currentAutosyncTimeoutMinutes * 60000,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]