From 7cc1832a1f7c18585cd6b7990626d6cc9960c1fb Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 11 Sep 2019 15:40:25 +0200 Subject: [PATCH] handle stream errors when checking for metadata --- storage/file.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/storage/file.js b/storage/file.js index b67132268..b14ec4b13 100644 --- a/storage/file.js +++ b/storage/file.js @@ -67,12 +67,8 @@ var getMetadataAtPath = function (Env, path, _cb) { } }, Util.mkAsync(_cb))); - try { - // stream creation can throw... probably ENOENT - stream = Fs.createReadStream(path, { encoding: 'utf8' }); - } catch (err) { - return void cb(err); - } + // stream creation emit errors... probably ENOENT + stream = Fs.createReadStream(path, { encoding: 'utf8' }).on('error', cb); // stream lines const rl = Readline.createInterface({