Add method for optimizing DBs
This commit is contained in:
parent
6bae3f7050
commit
878e73e5d7
|
@ -26,6 +26,7 @@ exports.nextConf = nextConf;
|
||||||
exports.prevArea = prevArea;
|
exports.prevArea = prevArea;
|
||||||
exports.nextArea = nextArea;
|
exports.nextArea = nextArea;
|
||||||
exports.sendForgotPasswordEmail = sendForgotPasswordEmail;
|
exports.sendForgotPasswordEmail = sendForgotPasswordEmail;
|
||||||
|
exports.optimizeDatabases = optimizeDatabases;
|
||||||
|
|
||||||
const handleAuthFailures = (callingMenu, err, cb) => {
|
const handleAuthFailures = (callingMenu, err, cb) => {
|
||||||
// already logged in with this user?
|
// already logged in with this user?
|
||||||
|
@ -205,3 +206,25 @@ function sendForgotPasswordEmail(callingMenu, formData, extraArgs, cb) {
|
||||||
return logoff(callingMenu, formData, extraArgs, cb);
|
return logoff(callingMenu, formData, extraArgs, cb);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function optimizeDatabases(callingMenu, formData, extraArgs, cb) {
|
||||||
|
const dbs = require('./database').dbs;
|
||||||
|
const client = callingMenu.client;
|
||||||
|
|
||||||
|
client.term.write('\r\n\r\n');
|
||||||
|
|
||||||
|
Object.keys(dbs).forEach(dbName => {
|
||||||
|
client.log.info({ dbName }, 'Optimizing database');
|
||||||
|
|
||||||
|
client.term.write(`Optimizing ${dbName}. Please wait...\r\n`);
|
||||||
|
|
||||||
|
// https://www.sqlite.org/pragma.html#pragma_optimize
|
||||||
|
dbs[dbName].run('PRAGMA optimize;', err => {
|
||||||
|
if (err) {
|
||||||
|
client.log.error({ error : err, dbName }, 'Error attempting to optimize database');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return callingMenu.prevMenu(cb);
|
||||||
|
}
|
Loading…
Reference in New Issue