From 1bf4addf638091c6b650667627e24a0b01d148c2 Mon Sep 17 00:00:00 2001 From: Hiroki Uchikawa <31908137+HirokiUchikawa@users.noreply.github.com> Date: Tue, 10 Jul 2018 20:41:16 +0900 Subject: [PATCH] Fix an error when initializing the cache (#1788) * Fix a error when initializing the cache * Make context directory if it is not there in initialization --- red/runtime/nodes/context/localfilesystem.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/red/runtime/nodes/context/localfilesystem.js b/red/runtime/nodes/context/localfilesystem.js index 28e1c4cce..89c7e6760 100644 --- a/red/runtime/nodes/context/localfilesystem.js +++ b/red/runtime/nodes/context/localfilesystem.js @@ -143,7 +143,13 @@ LocalFileSystem.prototype.open = function(){ self.cache.set(scope,key,data[key]); }) }); - }) + }).catch(function(err){ + if(err.code == 'ENOENT') { + return fs.mkdir(self.storageBaseDir); + }else{ + return Promise.reject(err); + } + }); } else { return Promise.resolve(); }