2016-08-22 03:18:31 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var fs = require('fs'),
|
2016-08-27 05:04:08 +00:00
|
|
|
path = require('path'),
|
2016-08-22 03:18:31 +00:00
|
|
|
_ = require('lodash');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Local Data Storage
|
|
|
|
*
|
|
|
|
* @param {Object} appconfig The application configuration
|
|
|
|
*/
|
|
|
|
module.exports = (appconfig) => {
|
|
|
|
|
2016-08-27 05:04:08 +00:00
|
|
|
// Create data directories
|
2016-08-22 03:18:31 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
fs.mkdirSync(appconfig.datadir.db);
|
|
|
|
} catch (err) {
|
|
|
|
if(err.code !== 'EEXIST') {
|
|
|
|
winston.error(err);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2016-08-27 05:04:08 +00:00
|
|
|
fs.mkdirSync(path.join(appconfig.datadir.db, 'cache'));
|
2016-08-22 03:18:31 +00:00
|
|
|
} catch (err) {
|
|
|
|
if(err.code !== 'EEXIST') {
|
|
|
|
winston.error(err);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|