mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-10-06 11:16:10 +08:00
[iso-core] Protect from operating on IMAP connection while opening a box
Summary: See title Test Plan: manual Reviewers: spang, mark Reviewed By: mark Differential Revision: https://phab.nylas.com/D4072
This commit is contained in:
parent
1f45c58aad
commit
3a626988c8
1 changed files with 9 additions and 5 deletions
|
@ -2,25 +2,23 @@ import Imap from 'imap';
|
||||||
import _ from 'underscore';
|
import _ from 'underscore';
|
||||||
import xoauth2 from 'xoauth2';
|
import xoauth2 from 'xoauth2';
|
||||||
import EventEmitter from 'events';
|
import EventEmitter from 'events';
|
||||||
|
|
||||||
import CommonProviderSettings from 'imap-provider-settings';
|
import CommonProviderSettings from 'imap-provider-settings';
|
||||||
|
|
||||||
import PromiseUtils from './promise-utils';
|
import PromiseUtils from './promise-utils';
|
||||||
import IMAPBox from './imap-box';
|
import IMAPBox from './imap-box';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
convertImapError,
|
convertImapError,
|
||||||
|
RetryableError,
|
||||||
IMAPConnectionTimeoutError,
|
IMAPConnectionTimeoutError,
|
||||||
IMAPConnectionNotReadyError,
|
IMAPConnectionNotReadyError,
|
||||||
IMAPConnectionEndedError,
|
IMAPConnectionEndedError,
|
||||||
} from './imap-errors';
|
} from './imap-errors';
|
||||||
|
|
||||||
|
|
||||||
const MAJOR_IMAP_PROVIDER_HOSTS = Object.keys(CommonProviderSettings).reduce(
|
const MAJOR_IMAP_PROVIDER_HOSTS = Object.keys(CommonProviderSettings).reduce(
|
||||||
(hostnameSet, key) => {
|
(hostnameSet, key) => {
|
||||||
hostnameSet.add(CommonProviderSettings[key].imap_host);
|
hostnameSet.add(CommonProviderSettings[key].imap_host);
|
||||||
return hostnameSet;
|
return hostnameSet;
|
||||||
}, new Set())
|
}, new Set())
|
||||||
|
|
||||||
const Capabilities = {
|
const Capabilities = {
|
||||||
Gmail: 'X-GM-EXT-1',
|
Gmail: 'X-GM-EXT-1',
|
||||||
Quota: 'QUOTA',
|
Quota: 'QUOTA',
|
||||||
|
@ -29,7 +27,6 @@ const Capabilities = {
|
||||||
Search: 'ESEARCH',
|
Search: 'ESEARCH',
|
||||||
Sort: 'SORT',
|
Sort: 'SORT',
|
||||||
}
|
}
|
||||||
|
|
||||||
const ONE_HOUR_SECS = 60 * 60;
|
const ONE_HOUR_SECS = 60 * 60;
|
||||||
const AUTH_TIMEOUT_MS = 30 * 1000;
|
const AUTH_TIMEOUT_MS = 30 * 1000;
|
||||||
const DEFAULT_SOCKET_TIMEOUT_MS = 30 * 1000;
|
const DEFAULT_SOCKET_TIMEOUT_MS = 30 * 1000;
|
||||||
|
@ -214,6 +211,10 @@ class IMAPConnection extends EventEmitter {
|
||||||
throw new IMAPConnectionNotReadyError(`IMAPConnection::_withPreparedConnection`)
|
throw new IMAPConnectionNotReadyError(`IMAPConnection::_withPreparedConnection`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this._isOpeningBox) {
|
||||||
|
throw new RetryableError('IMAPConnection: Cannot operate on connection while opening a box.')
|
||||||
|
}
|
||||||
|
|
||||||
let onEnded = null;
|
let onEnded = null;
|
||||||
let onErrored = null;
|
let onErrored = null;
|
||||||
|
|
||||||
|
@ -299,6 +300,9 @@ class IMAPConnection extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
getLastOpenDuration() {
|
getLastOpenDuration() {
|
||||||
|
if (this._isOpeningBox) {
|
||||||
|
throw new RetryableError('IMAPConnection: Cannot operate on connection while opening a box.')
|
||||||
|
}
|
||||||
return this._lastOpenDuration;
|
return this._lastOpenDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue