Use curve functions from native module

This commit is contained in:
Scott Nonnenberg
2019-08-19 15:26:45 -07:00
parent e29eee4583
commit d3d2b0ec52
20 changed files with 623 additions and 74127 deletions

View File

@@ -1160,9 +1160,11 @@ async function initialize({ configDir, key, messages }) {
filePath = join(dbDir, 'db.sqlite');
let promisified;
try {
const sqlInstance = await openDatabase(filePath);
const promisified = promisify(sqlInstance);
promisified = promisify(sqlInstance);
// promisified.on('trace', async statement => {
// if (!db || statement.startsWith('--')) {
@@ -1177,16 +1179,18 @@ async function initialize({ configDir, key, messages }) {
await updateSchema(promisified);
db = promisified;
// test database
const result = await getSQLIntegrityCheck(db);
const result = await getSQLIntegrityCheck(promisified);
if (result) {
console.log('Database integrity check failed:', result);
throw new Error(`Integrity check failed: ${result}`);
}
// At this point we can allow general access to the database
db = promisified;
// test database
await getMessageCount();
} catch (error) {
console.log('Database startup error:', error.stack);
@@ -1207,7 +1211,9 @@ async function initialize({ configDir, key, messages }) {
`Database startup error:\n\n${redactAll(error.stack)}`
);
} else {
await close();
if (promisified) {
await promisified.close();
}
await removeDB();
removeUserConfig();
app.relaunch();