From ece519553fc94e5036aa345e241d0a316671768c Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Tue, 29 Nov 2016 18:02:25 -0800 Subject: [PATCH] fix(sync): Issue with CONDSTORE args not passed to fetch --- packages/isomorphic-core/src/imap-box.js | 4 ++-- .../imap/fetch-messages-in-folder.js | 12 ++++++------ .../local-sync/src/local-sync-worker/sync-worker.js | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/isomorphic-core/src/imap-box.js b/packages/isomorphic-core/src/imap-box.js index c0f08662f..ab91f5be4 100644 --- a/packages/isomorphic-core/src/imap-box.js +++ b/packages/isomorphic-core/src/imap-box.js @@ -124,10 +124,10 @@ class IMAPBox { * @return {Promise} that resolves to a map of uid -> attributes for every * message in the range */ - fetchUIDAttributes(range) { + fetchUIDAttributes(range, fetchOptions = {}) { return this._conn.createConnectionPromise((resolve, reject) => { const attributesByUID = {}; - const f = this._conn._imap.fetch(range, {}); + const f = this._conn._imap.fetch(range, fetchOptions); f.on('message', (msg) => { msg.on('attributes', (attrs) => { attributesByUID[attrs.uid] = attrs; diff --git a/packages/local-sync/src/local-sync-worker/imap/fetch-messages-in-folder.js b/packages/local-sync/src/local-sync-worker/imap/fetch-messages-in-folder.js index 1580eadee..fa7f59fb8 100644 --- a/packages/local-sync/src/local-sync-worker/imap/fetch-messages-in-folder.js +++ b/packages/local-sync/src/local-sync-worker/imap/fetch-messages-in-folder.js @@ -18,7 +18,7 @@ class FetchMessagesInFolder { this._db = null this._category = category; this._options = options; - this._logger = logger; + this._logger = logger.child({category_name: this._category.name}); if (!this._logger) { throw new Error("FetchMessagesInFolder requires a logger") } @@ -124,14 +124,14 @@ class FetchMessagesInFolder { .filter(msg => !remoteUIDAttributes[msg.folderImapUID]) .map(msg => msg.folderImapUID) - this._logger.info({ - removed_messages: removedUIDs.length, - }, `FetchMessagesInFolder: found messages no longer in the folder`) - if (removedUIDs.length === 0) { return; } + this._logger.info({ + removed_messages: removedUIDs.length, + }, `FetchMessagesInFolder: found messages no longer in the folder`) + await this._db.sequelize.transaction((transaction) => Message.update({ folderImapUID: null, @@ -248,7 +248,7 @@ class FetchMessagesInFolder { } async _openMailboxAndEnsureValidity() { - const box = this._imap.openBox(this._category.name); + const box = await this._imap.openBox(this._category.name); if (box.persistentUIDs === false) { throw new Error("Mailbox does not support persistentUIDs."); diff --git a/packages/local-sync/src/local-sync-worker/sync-worker.js b/packages/local-sync/src/local-sync-worker/sync-worker.js index 16f2a4896..43a455681 100644 --- a/packages/local-sync/src/local-sync-worker/sync-worker.js +++ b/packages/local-sync/src/local-sync-worker/sync-worker.js @@ -216,7 +216,7 @@ class SyncWorker { const target = this._lastSyncTime + (moreToSync ? 1 : intervals.active); - this._logger.info(`SyncWorker: Scheduling next sync iteration for ${target - Date.now()}ms}`) + this._logger.info(`SyncWorker: Scheduling next sync iteration for ${target - Date.now()}ms`) this._syncTimer = setTimeout(() => { this.syncNow({reason: 'Scheduled'});