From 5713d37046cc981fceec0c20f8cff86a35e04bb2 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 4 Feb 2013 16:59:46 -0800 Subject: [PATCH] Don't allow sync thread to do anything if migration hasn't occurred yet --- .../com/todoroo/astrid/actfm/sync/ActFmSyncThread.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncThread.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncThread.java index 953186c0a..da3105f89 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncThread.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncThread.java @@ -17,6 +17,7 @@ import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.sql.Query; import com.todoroo.andlib.utility.AndroidUtilities; +import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.actfm.sync.messages.BriefMe; import com.todoroo.astrid.actfm.sync.messages.ChangesHappened; import com.todoroo.astrid.actfm.sync.messages.ClientToServerMessage; @@ -49,6 +50,7 @@ public class ActFmSyncThread { private final List> pendingMessages; private final List pendingCallbacks; private final Object monitor; + private boolean migrationHasOccurred; private Thread thread; @Autowired @@ -122,6 +124,7 @@ public class ActFmSyncThread { this.pendingMessages = messageQueue; this.pendingCallbacks = callbackQueue; this.monitor = syncMonitor; + this.migrationHasOccurred = Preferences.getBoolean(AstridNewSyncMigrator.PREF_SYNC_MIGRATION, false); } public synchronized void startSyncThread() { @@ -156,10 +159,13 @@ public class ActFmSyncThread { List callbackBatch = new LinkedList(); while(true) { synchronized(monitor) { - while ((pendingMessages.isEmpty() && !timeForBackgroundSync()) || !actFmPreferenceService.isLoggedIn()) { + while ((pendingMessages.isEmpty() && !timeForBackgroundSync()) || !actFmPreferenceService.isLoggedIn() || !migrationHasOccurred) { try { monitor.wait(); AndroidUtilities.sleepDeep(500L); // Wait briefly for large database operations to finish (e.g. adding a task with several tags may trigger a message before all saves are done--fix this?) + + if (!migrationHasOccurred) + migrationHasOccurred = Preferences.getBoolean(AstridNewSyncMigrator.PREF_SYNC_MIGRATION, false); } catch (InterruptedException e) { // Ignored }