mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
parent
9777af7cb5
commit
c1d50e82e1
@ -140,9 +140,9 @@ function stringify(value) {
|
|||||||
function LocalFileSystem(config){
|
function LocalFileSystem(config){
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.storageBaseDir = getBasePath(this.config);
|
this.storageBaseDir = getBasePath(this.config);
|
||||||
|
this.writePromise = Promise.resolve();
|
||||||
if (config.hasOwnProperty('cache')?config.cache:true) {
|
if (config.hasOwnProperty('cache')?config.cache:true) {
|
||||||
this.cache = MemoryStore({});
|
this.cache = MemoryStore({});
|
||||||
this.writePromise = Promise.resolve();
|
|
||||||
}
|
}
|
||||||
this.pendingWrites = {};
|
this.pendingWrites = {};
|
||||||
this.knownCircularRefs = {};
|
this.knownCircularRefs = {};
|
||||||
@ -219,9 +219,8 @@ LocalFileSystem.prototype.close = function(){
|
|||||||
clearTimeout(this._pendingWriteTimeout);
|
clearTimeout(this._pendingWriteTimeout);
|
||||||
delete this._pendingWriteTimeout;
|
delete this._pendingWriteTimeout;
|
||||||
this.flushInterval = 0;
|
this.flushInterval = 0;
|
||||||
return this.writePromise;
|
|
||||||
}
|
}
|
||||||
return Promise.resolve();
|
return this.writePromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalFileSystem.prototype.get = function(scope, key, callback) {
|
LocalFileSystem.prototype.get = function(scope, key, callback) {
|
||||||
@ -290,7 +289,7 @@ LocalFileSystem.prototype.set = function(scope, key, value, callback) {
|
|||||||
} else if (callback && typeof callback !== 'function') {
|
} else if (callback && typeof callback !== 'function') {
|
||||||
throw new Error("Callback must be a function");
|
throw new Error("Callback must be a function");
|
||||||
} else {
|
} else {
|
||||||
loadFile(storagePath + ".json").then(function(data){
|
self.writePromise = self.writePromise.then(function() { return loadFile(storagePath + ".json") }).then(function(data){
|
||||||
var obj = data ? JSON.parse(data) : {}
|
var obj = data ? JSON.parse(data) : {}
|
||||||
if (!Array.isArray(key)) {
|
if (!Array.isArray(key)) {
|
||||||
key = [key];
|
key = [key];
|
||||||
|
Loading…
Reference in New Issue
Block a user