[client-app] Handle errors when opening imap box correctly

Summary:
If an error is thrown while opening an imap box, we need to make sure to
set the `_isOpening` back to false

Test Plan: manual

Reviewers: mark

Reviewed By: mark

Differential Revision: https://phab.nylas.com/D4134
This commit is contained in:
Juan Tejada 2017-03-08 09:48:04 -08:00
parent bec943e1e3
commit ef4778d12a

View file

@ -289,13 +289,17 @@ class IMAPConnection extends EventEmitter {
return Promise.resolve(new IMAPBox(this, this._imap._box));
}
return this._withPreparedConnection(async (imap) => {
this._isOpeningBox = true
this._lastOpenDuration = null;
const before = Date.now();
const box = await imap.openBoxAsync(folderName, readOnly)
this._lastOpenDuration = Date.now() - before;
this._isOpeningBox = false
return new IMAPBox(this, box)
try {
this._isOpeningBox = true
this._lastOpenDuration = null;
const before = Date.now();
const box = await imap.openBoxAsync(folderName, readOnly)
this._lastOpenDuration = Date.now() - before;
this._isOpeningBox = false
return new IMAPBox(this, box)
} finally {
this._isOpeningBox = false
}
})
}