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

LocalFileSystem Context: Remove extra flush code

This commit is contained in:
Nick O'Leary 2018-09-16 22:04:09 +01:00
parent fd86035865
commit 9777af7cb5
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -204,22 +204,8 @@ LocalFileSystem.prototype.open = function(){
log.debug("Flushing localfilesystem context scope "+scope); log.debug("Flushing localfilesystem context scope "+scope);
promises.push(fs.outputFile(storagePath + ".json", stringifiedContext.json, "utf8")); promises.push(fs.outputFile(storagePath + ".json", stringifiedContext.json, "utf8"));
}); });
return Promise.all(promises).then(function(){ delete self._pendingWriteTimeout;
if(Object.keys(self.pendingWrites).length > 0){ return Promise.all(promises);
// Rerun flushing if pendingWrites was added when the promise was running
return new Promise(function(resolve, reject) {
setTimeout(function() {
self._flushPendingWrites.call(self).then(function(){
resolve();
}).catch(function(err) {
reject(err);
});
}, self.flushInterval);
});
} else {
delete self._pendingWriteTimeout;
}
});
} }
}); });
} else { } else {
@ -233,11 +219,7 @@ 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.then(function(){ return this.writePromise;
if(Object.keys(self.pendingWrites).length > 0) {
return self._flushPendingWrites();
}
});
} }
return Promise.resolve(); return Promise.resolve();
} }