From 1cd7df136953d1c278ae238e8039f5b8da979620 Mon Sep 17 00:00:00 2001 From: cketti Date: Fri, 22 May 2015 03:41:24 +0200 Subject: [PATCH] Don't write the new push state to the database for every message --- .../com/fsck/k9/controller/MessagingController.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java b/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java index 93687f60d..c7f26ae73 100644 --- a/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java +++ b/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java @@ -1296,14 +1296,15 @@ public class MessagingController implements Runnable { fetchUnsyncedMessages(account, remoteFolder, localFolder, unsyncedMessages, smallMessages, largeMessages, progress, todo, fp); - // If a message didn't exist, messageFinished won't be called, but we shouldn't try again - // If we got here, nothing failed + String updatedPushState = localFolder.getPushState(); for (Message message : unsyncedMessages) { - String newPushState = remoteFolder.getNewPushState(localFolder.getPushState(), message); + String newPushState = remoteFolder.getNewPushState(updatedPushState, message); if (newPushState != null) { - localFolder.setPushState(newPushState); + updatedPushState = newPushState; } } + localFolder.setPushState(updatedPushState); + if (K9.DEBUG) { Log.d(K9.LOG_TAG, "SYNC: Synced unsynced messages for folder " + folder); } @@ -1462,10 +1463,6 @@ public class MessagingController implements Runnable { @Override public void messageFinished(T message, int number, int ofTotal) { try { - String newPushState = remoteFolder.getNewPushState(localFolder.getPushState(), message); - if (newPushState != null) { - localFolder.setPushState(newPushState); - } if (message.isSet(Flag.DELETED) || message.olderThan(earliestDate)) { if (K9.DEBUG) {