Insert Image model + Uploads Folders list
This commit is contained in:
@@ -6,7 +6,7 @@ var loki = require('lokijs'),
|
||||
Promise = require('bluebird'),
|
||||
_ = require('lodash');
|
||||
|
||||
var cols = ['User','Entry'];
|
||||
var cols = ['User', 'Entry'];
|
||||
|
||||
/**
|
||||
* Loki.js module
|
||||
|
@@ -119,7 +119,7 @@ module.exports = {
|
||||
winston.error('Git remote error!');
|
||||
throw err;
|
||||
}).then(() => {
|
||||
winston.info('[GIT] Git repository is now ready.');
|
||||
winston.info('[GIT] Git repository is OK.');
|
||||
return true;
|
||||
});
|
||||
|
||||
|
@@ -9,26 +9,96 @@ var fs = require('fs'),
|
||||
*
|
||||
* @param {Object} appconfig The application configuration
|
||||
*/
|
||||
module.exports = (appconfig) => {
|
||||
module.exports = {
|
||||
|
||||
// Create data directories
|
||||
_uploadsPath: './repo/uploads',
|
||||
_uploadsFolders: [],
|
||||
|
||||
try {
|
||||
fs.mkdirSync(appconfig.datadir.db);
|
||||
} catch (err) {
|
||||
if(err.code !== 'EEXIST') {
|
||||
winston.error(err);
|
||||
process.exit(1);
|
||||
/**
|
||||
* Initialize Local Data Storage model
|
||||
*
|
||||
* @param {Object} appconfig The application config
|
||||
* @return {Object} Local Data Storage model instance
|
||||
*/
|
||||
init(appconfig, skipFolderCreation = false) {
|
||||
|
||||
let self = this;
|
||||
|
||||
self._uploadsPath = path.join(ROOTPATH, appconfig.datadir.db, 'uploads');
|
||||
|
||||
// Create data directories
|
||||
|
||||
if(!skipFolderCreation) {
|
||||
self.createBaseDirectories(appconfig);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
fs.mkdirSync(path.join(appconfig.datadir.db, 'cache'));
|
||||
} catch (err) {
|
||||
if(err.code !== 'EEXIST') {
|
||||
winston.error(err);
|
||||
process.exit(1);
|
||||
return self;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a base directories (Synchronous).
|
||||
*
|
||||
* @param {Object} appconfig The application config
|
||||
* @return {Void} Void
|
||||
*/
|
||||
createBaseDirectories(appconfig) {
|
||||
|
||||
winston.info('[SERVER] Create data directories if they don\'t exist...');
|
||||
|
||||
try {
|
||||
fs.mkdirSync(appconfig.datadir.db);
|
||||
} catch (err) {
|
||||
if(err.code !== 'EEXIST') {
|
||||
winston.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
fs.mkdirSync(path.join(appconfig.datadir.db, 'cache'));
|
||||
} catch (err) {
|
||||
if(err.code !== 'EEXIST') {
|
||||
winston.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
fs.mkdirSync(path.join(appconfig.datadir.db, 'thumbs'));
|
||||
} catch (err) {
|
||||
if(err.code !== 'EEXIST') {
|
||||
winston.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
winston.info('[SERVER] Data directories are OK.');
|
||||
|
||||
return;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the uploads folders.
|
||||
*
|
||||
* @param {Array<String>} arrFolders The arr folders
|
||||
* @return {Void} Void
|
||||
*/
|
||||
setUploadsFolders(arrFolders) {
|
||||
|
||||
this._uploadsFolders = arrFolders;
|
||||
return;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the uploads folders.
|
||||
*
|
||||
* @return {Array<String>} The uploads folders.
|
||||
*/
|
||||
getUploadsFolders() {
|
||||
return this._uploadsFolders;
|
||||
}
|
||||
|
||||
};
|
Reference in New Issue
Block a user