From 978f4ecc58a4348215d7edbec8a56eba471fdb05 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 13 Dec 2018 12:46:19 +0000 Subject: [PATCH] Ensure fs context cache is flushed on close Fixes #2001 --- .../@node-red/runtime/lib/nodes/context/localfilesystem.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/node_modules/@node-red/runtime/lib/nodes/context/localfilesystem.js b/packages/node_modules/@node-red/runtime/lib/nodes/context/localfilesystem.js index cfbd8e8f6..10b4349b8 100644 --- a/packages/node_modules/@node-red/runtime/lib/nodes/context/localfilesystem.js +++ b/packages/node_modules/@node-red/runtime/lib/nodes/context/localfilesystem.js @@ -209,6 +209,7 @@ LocalFileSystem.prototype.open = function(){ } }); } else { + self._flushPendingWrites = function() { } return fs.ensureDir(self.storageBaseDir); } } @@ -219,6 +220,12 @@ LocalFileSystem.prototype.close = function(){ clearTimeout(this._pendingWriteTimeout); delete this._pendingWriteTimeout; this.flushInterval = 0; + self.writePromise = self.writePromise.then(function(){ + return self._flushPendingWrites.call(self).catch(function(err) { + log.error(log._("context.localfilesystem.error-write",{message:err.toString()})); + }); + }); + } return this.writePromise; }