From a8173dc7ea368f04aeaa45c030e6a8bd04fae32f Mon Sep 17 00:00:00 2001 From: Tim Su Date: Thu, 8 Apr 2010 01:16:59 -0700 Subject: [PATCH] Surround more synchronization logic with try-catch, hope this makes things more resilient --- .../astrid/sync/SynchronizationProvider.java | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/com/timsu/astrid/sync/SynchronizationProvider.java b/src/com/timsu/astrid/sync/SynchronizationProvider.java index eca073e78..4b0968231 100644 --- a/src/com/timsu/astrid/sync/SynchronizationProvider.java +++ b/src/com/timsu/astrid/sync/SynchronizationProvider.java @@ -213,7 +213,7 @@ public abstract class SynchronizationProvider { * @param remoteTasks remote tasks that have been updated * @return local tasks that need to be pushed across */ - protected void synchronizeTasks(final Context context, LinkedList + protected synchronized void synchronizeTasks(final Context context, LinkedList remoteTasks, SynchronizeHelper helper) throws IOException { final SyncStats stats = new SyncStats(); final StringBuilder log = new StringBuilder(); @@ -284,19 +284,24 @@ public abstract class SynchronizationProvider { // 3. UPDATE: for each updated local task for(SyncMapping mapping : data.localChanges) { - TaskProxy localTask = new TaskProxy(getId(), mapping.getRemoteId()); - TaskModelForSync task = taskController.fetchTaskForSync( - mapping.getTask()); - if(task == null) { - // sucks... task was deleted i guess. - continue; + try { + TaskProxy localTask = new TaskProxy(getId(), mapping.getRemoteId()); + TaskModelForSync task = taskController.fetchTaskForSync( + mapping.getTask()); + if(task == null) { + // sucks... task was deleted i guess. + continue; + } + localTask.readFromTaskModel(task); + localTask.readTagsFromController(task.getTaskIdentifier(), + tagController, data.tags); + postUpdate(new ProgressLabelUpdater(context, R.string.sync_progress_localtx, + task.getName())); + } catch (Exception e) { + AstridUtilities.reportFlurryError("sync-read-local-task", e); + Log.e("astrid", "Exception receiving task", e); + log.append("error reading local task\n"); } - localTask.readFromTaskModel(task); - localTask.readTagsFromController(task.getTaskIdentifier(), - tagController, data.tags); - - postUpdate(new ProgressLabelUpdater(context, R.string.sync_progress_localtx, - task.getName())); postUpdate(new ProgressUpdater(stats.remoteUpdatedTasks, data.localChanges.size()));