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

Clone settings before passing to storage layer

Avoids the storage layer modifying the in-memory object
This commit is contained in:
Nick O'Leary 2020-09-28 10:40:03 +01:00
parent 1a4d720978
commit bb4330e486
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -92,7 +92,7 @@ var persistentSettings = {
assert.deepEqual(current,value); assert.deepEqual(current,value);
return when.resolve(); return when.resolve();
} catch(err) { } catch(err) {
return storage.saveSettings(globalSettings); return storage.saveSettings(clone(globalSettings));
} }
}, },
delete: function(prop) { delete: function(prop) {
@ -104,7 +104,7 @@ var persistentSettings = {
} }
if (globalSettings.hasOwnProperty(prop)) { if (globalSettings.hasOwnProperty(prop)) {
delete globalSettings[prop]; delete globalSettings[prop];
return storage.saveSettings(globalSettings); return storage.saveSettings(clone(globalSettings));
} }
return when.resolve(); return when.resolve();
}, },
@ -183,7 +183,7 @@ var persistentSettings = {
return when.resolve(); return when.resolve();
} catch(err) { } catch(err) {
globalSettings.users = userSettings; globalSettings.users = userSettings;
return storage.saveSettings(globalSettings); return storage.saveSettings(clone(globalSettings));
} }
} }
} }