1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Cache settings when doing initial load

This commit is contained in:
Nick O'Leary 2020-09-28 10:41:05 +01:00
parent bb4330e486
commit e6ffa3d143
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -88,11 +88,13 @@ async function readSettings() {
// Read the 'runtime' settings file first // Read the 'runtime' settings file first
const runtimeFilename = getSettingsFilename("runtime"); const runtimeFilename = getSettingsFilename("runtime");
const result = await util.readFile(runtimeFilename,runtimeFilename+".backup",{}); const result = await util.readFile(runtimeFilename,runtimeFilename+".backup",{});
settingsCache["runtime"] = JSON.stringify(result, null ,4);
const readPromises = []; const readPromises = [];
// Read the other settings files and add them into the runtime settings // Read the other settings files and add them into the runtime settings
configSections.forEach(key => { configSections.forEach(key => {
const sectionFilename = getSettingsFilename(key); const sectionFilename = getSettingsFilename(key);
readPromises.push(util.readFile(sectionFilename,sectionFilename+".backup",{}).then(sectionData => { readPromises.push(util.readFile(sectionFilename,sectionFilename+".backup",{}).then(sectionData => {
settingsCache[key] = JSON.stringify(sectionData, null ,4);
if (Object.keys(sectionData).length > 0) { if (Object.keys(sectionData).length > 0) {
result[key] = sectionData; result[key] = sectionData;
} }