mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-01 13:14:16 +08:00
Ensure error codes are displayed and db migrate runs synchronously
This commit is contained in:
parent
d0a91bea80
commit
eaae6ff197
2 changed files with 14 additions and 14 deletions
|
@ -47,17 +47,6 @@ export default class Application extends EventEmitter {
|
||||||
const mailsync = new MailsyncProcess(options, null);
|
const mailsync = new MailsyncProcess(options, null);
|
||||||
await mailsync.migrate();
|
await mailsync.migrate();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const callback = buttonIndex => {
|
|
||||||
if (buttonIndex === 0) {
|
|
||||||
app.quit();
|
|
||||||
} else {
|
|
||||||
this._deleteDatabase(() => {
|
|
||||||
app.relaunch();
|
|
||||||
app.quit();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let message = null;
|
let message = null;
|
||||||
let buttons = ['Quit'];
|
let buttons = ['Quit'];
|
||||||
if (err.toString().includes('ENOENT')) {
|
if (err.toString().includes('ENOENT')) {
|
||||||
|
@ -69,7 +58,17 @@ export default class Application extends EventEmitter {
|
||||||
buttons = ['Quit', 'Rebuild'];
|
buttons = ['Quit', 'Rebuild'];
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog.showMessageBox({ type: 'warning', buttons, message }, callback);
|
const buttonIndex = dialog.showMessageBox({ type: 'warning', buttons, message });
|
||||||
|
|
||||||
|
if (buttonIndex === 0) {
|
||||||
|
app.quit();
|
||||||
|
} else {
|
||||||
|
this._deleteDatabase(() => {
|
||||||
|
app.relaunch();
|
||||||
|
app.quit();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Config = require('../config');
|
const Config = require('../config');
|
||||||
|
|
|
@ -103,7 +103,8 @@ export default class MailsyncProcess extends EventEmitter {
|
||||||
|
|
||||||
this._proc.on('close', code => {
|
this._proc.on('close', code => {
|
||||||
const stripSecrets = text => {
|
const stripSecrets = text => {
|
||||||
const { refresh_token, imap_password, smtp_password } = this.account.settings;
|
const settings = (this.account && this.account.settings) || {};
|
||||||
|
const { refresh_token, imap_password, smtp_password } = settings;
|
||||||
return (text || '')
|
return (text || '')
|
||||||
.replace(new RegExp(refresh_token || 'not-present', 'g'), '*********')
|
.replace(new RegExp(refresh_token || 'not-present', 'g'), '*********')
|
||||||
.replace(new RegExp(imap_password || 'not-present', 'g'), '*********')
|
.replace(new RegExp(imap_password || 'not-present', 'g'), '*********')
|
||||||
|
@ -128,7 +129,7 @@ export default class MailsyncProcess extends EventEmitter {
|
||||||
reject(error);
|
reject(error);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const error = new Error('An unexpected error occurred - view the raw log for details.');
|
const error = new Error(`An unexpected mailsync error occurred (${code})`);
|
||||||
error.rawLog = stripSecrets(buffer.toString());
|
error.rawLog = stripSecrets(buffer.toString());
|
||||||
reject(error);
|
reject(error);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue