mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge pull request #2737 from node-red/fix-async-settings
Add mutex lock to saveSettings storage call
This commit is contained in:
commit
c38a490a6f
@ -25,6 +25,9 @@ var storageModule;
|
|||||||
var settingsAvailable;
|
var settingsAvailable;
|
||||||
var sessionsAvailable;
|
var sessionsAvailable;
|
||||||
|
|
||||||
|
var Mutex = require('async-mutex').Mutex;
|
||||||
|
const settingsSaveMutex = new Mutex();
|
||||||
|
|
||||||
var libraryFlowsCachedResult = null;
|
var libraryFlowsCachedResult = null;
|
||||||
|
|
||||||
function moduleSelector(aSettings) {
|
function moduleSelector(aSettings) {
|
||||||
@ -114,7 +117,7 @@ var storageModuleInterface = {
|
|||||||
},
|
},
|
||||||
saveSettings: function(settings) {
|
saveSettings: function(settings) {
|
||||||
if (settingsAvailable) {
|
if (settingsAvailable) {
|
||||||
return storageModule.saveSettings(settings);
|
return settingsSaveMutex.runExclusive(() => storageModule.saveSettings(settings))
|
||||||
} else {
|
} else {
|
||||||
return when.resolve();
|
return when.resolve();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user