From 50f00e51745051e079eea034a41f8a89718d12fc Mon Sep 17 00:00:00 2001 From: Juan Tejada Date: Sat, 14 Jan 2017 17:36:02 -0800 Subject: [PATCH] [local-sync] Fix order of execution in fetch-messages-in-folder --- .../sync-tasks/fetch-messages-in-folder.imap.es6 | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/local-sync/src/local-sync-worker/sync-tasks/fetch-messages-in-folder.imap.es6 b/packages/local-sync/src/local-sync-worker/sync-tasks/fetch-messages-in-folder.imap.es6 index 16930449d..c4443d249 100644 --- a/packages/local-sync/src/local-sync-worker/sync-tasks/fetch-messages-in-folder.imap.es6 +++ b/packages/local-sync/src/local-sync-worker/sync-tasks/fetch-messages-in-folder.imap.es6 @@ -506,6 +506,13 @@ class FetchMessagesInFolderIMAP extends SyncTask { this._db = db; this._imap = imap; + const shouldSyncFolder = yield this._shouldSyncFolder() + if (!shouldSyncFolder) { + console.log(`🔚 📂 ${this._folder.name} has no updates - skipping sync`) + return; + } + + this._box = yield this._openMailboxAndEnsureValidity(); // If we haven't set any syncState at all, let's set it for the first time // to generate a delta for N1 if (_.isEmpty(this._folder.syncState)) { @@ -517,14 +524,6 @@ class FetchMessagesInFolderIMAP extends SyncTask { failedUIDs: [], }) } - - const shouldSyncFolder = yield this._shouldSyncFolder() - if (!shouldSyncFolder) { - console.log(`🔚 📂 ${this._folder.name} has no updates - skipping sync`) - return; - } - - this._box = yield this._openMailboxAndEnsureValidity(); yield this._fetchUnsyncedMessages(); yield this._fetchMessageAttributeChanges(); console.log(`🔚 📂 ${this._folder.name} done`)