From d6fc35cab40b76bed91568701443480ed65e6e36 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 26 Aug 2019 17:44:21 +0200 Subject: [PATCH] mkdirp the path to metadata before writing --- storage/file.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/storage/file.js b/storage/file.js index cbb45138d..739f079ec 100644 --- a/storage/file.js +++ b/storage/file.js @@ -236,8 +236,13 @@ How to proceed // writeMetadata appends to the dedicated log of metadata amendments var writeMetadata = function (env, channelId, data, cb) { var path = mkMetadataPath(env, channelId); - // TODO see if we can make this any faster by using something other than appendFile - Fs.appendFile(path, data + '\n', cb); + + Fse.mkdirp(Path.dirname(path), PERMISSIVE, function (err) { + if (err && err.code !== 'EEXIST') { return void cb(err); } + + // TODO see if we can make this any faster by using something other than appendFile + Fs.appendFile(path, data + '\n', cb); + }); };