Fix bug where always closing connection after sync

This commit is contained in:
Ben Gotow 2016-06-28 18:43:53 -07:00
parent 0189e3e77d
commit c7422ffaea
3 changed files with 11 additions and 10 deletions

View file

@ -13,5 +13,5 @@ module.exports = {
reply(Serialization.jsonStringify(syncbackRequest))
})
})
}
},
}

View file

@ -47,7 +47,7 @@ const notifyAccountIsActive = (accountId) => {
if (val === 1) {
PubsubConnector.notify({
accountId: accountId,
type: MessageTypes.ACCOUNT_UPDATED
type: MessageTypes.ACCOUNT_UPDATED,
});
}
});

View file

@ -1,5 +1,4 @@
const {
Provider,
SchedulerUtils,
IMAPConnection,
PubsubConnector,
@ -74,16 +73,18 @@ class SyncWorker {
.then((inboxCategory) => this._conn.openBox(inboxCategory.name))
.then(() => console.log('SyncWorker: - Idling on inbox category'))
.catch((error) => {
this.closeConnection()
console.error('SyncWorker: - Unhandled error while attempting to idle on Inbox after sync: ', error)
this.closeConnection()
})
} else if (afterSync === 'close') {
console.log('SyncWorker: - Closing connection');
} else {
console.warn(`SyncWorker: - Unknown afterSync behavior: ${afterSync}. Closing connection`)
}
this.closeConnection()
return Promise.resolve()
if (afterSync === 'close') {
console.log('SyncWorker: - Closing connection');
this.closeConnection()
return Promise.resolve()
}
throw new Error(`SyncWorker.onSyncDidComplete: Unknown afterSync behavior: ${afterSync}. Closing connection`)
}
onConnectionIdleUpdate() {