mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-06 12:47:13 +02:00
More Hot-Reload related changes
* Config.get(): Returns the latest config * Update code all over the place to use Config.get() vs Config.conf (which will be deprecated)
This commit is contained in:
parent
ca0149eaf0
commit
1fe46894d3
42 changed files with 320 additions and 273 deletions
|
@ -2,7 +2,7 @@
|
|||
'use strict';
|
||||
|
||||
// ENiGMA½
|
||||
const Config = require('./config.js').config;
|
||||
const Config = require('./config.js').get;
|
||||
const stringFormat = require('./string_format.js');
|
||||
const Errors = require('./enig_error.js').Errors;
|
||||
const resolveMimeType = require('./mime_util.js').resolveMimeType;
|
||||
|
@ -61,10 +61,11 @@ module.exports = class ArchiveUtil {
|
|||
//
|
||||
// Load configuration
|
||||
//
|
||||
if(_.has(Config, 'archives.archivers')) {
|
||||
Object.keys(Config.archives.archivers).forEach(archKey => {
|
||||
const config = Config();
|
||||
if(_.has(config, 'archives.archivers')) {
|
||||
Object.keys(config.archives.archivers).forEach(archKey => {
|
||||
|
||||
const archConfig = Config.archives.archivers[archKey];
|
||||
const archConfig = config.archives.archivers[archKey];
|
||||
const archiver = new Archiver(archConfig);
|
||||
|
||||
if(!archiver.ok()) {
|
||||
|
@ -75,7 +76,7 @@ module.exports = class ArchiveUtil {
|
|||
});
|
||||
}
|
||||
|
||||
if(_.isObject(Config.fileTypes)) {
|
||||
if(_.isObject(config.fileTypes)) {
|
||||
const updateSig = (ft) => {
|
||||
ft.sig = Buffer.from(ft.sig, 'hex');
|
||||
ft.offset = ft.offset || 0;
|
||||
|
@ -87,8 +88,8 @@ module.exports = class ArchiveUtil {
|
|||
}
|
||||
};
|
||||
|
||||
Object.keys(Config.fileTypes).forEach(mimeType => {
|
||||
const fileType = Config.fileTypes[mimeType];
|
||||
Object.keys(config.fileTypes).forEach(mimeType => {
|
||||
const fileType = config.fileTypes[mimeType];
|
||||
if(Array.isArray(fileType)) {
|
||||
fileType.forEach(ft => {
|
||||
if(ft.sig) {
|
||||
|
@ -109,7 +110,8 @@ module.exports = class ArchiveUtil {
|
|||
return;
|
||||
}
|
||||
|
||||
let fileType = _.get(Config, [ 'fileTypes', mimeType ] );
|
||||
const config = Config();
|
||||
let fileType = _.get(config, [ 'fileTypes', mimeType ] );
|
||||
|
||||
if(Array.isArray(fileType)) {
|
||||
if(!justExtention) {
|
||||
|
@ -125,7 +127,7 @@ module.exports = class ArchiveUtil {
|
|||
}
|
||||
|
||||
if(fileType.archiveHandler) {
|
||||
return _.get( Config, [ 'archives', 'archivers', fileType.archiveHandler ] );
|
||||
return _.get( config, [ 'archives', 'archivers', fileType.archiveHandler ] );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,7 +153,7 @@ module.exports = class ArchiveUtil {
|
|||
return cb(err);
|
||||
}
|
||||
|
||||
const archFormat = _.findKey(Config.fileTypes, fileTypeInfo => {
|
||||
const archFormat = _.findKey(Config().fileTypes, fileTypeInfo => {
|
||||
const fileTypeInfos = Array.isArray(fileTypeInfo) ? fileTypeInfo : [ fileTypeInfo ];
|
||||
return fileTypeInfos.find(fti => {
|
||||
if(!fti.sig || !fti.archiveHandler) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue