From 744be9929f452c906659ffec4c1986526161aabb Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 23 Sep 2019 11:17:42 +0200 Subject: [PATCH] handle stream errors when uploading --- storage/blob.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/storage/blob.js b/storage/blob.js index 6b3e891dd..759839fd8 100644 --- a/storage/blob.js +++ b/storage/blob.js @@ -74,7 +74,8 @@ var isFile = function (filePath, cb) { }); }; -var makeFileStream = function (full, cb) { +var makeFileStream = function (full, _cb) { + var cb = Util.once(Util.mkAsync(_cb)); Fse.mkdirp(Path.dirname(full), function (e) { if (e || !full) { // !full for pleasing flow, it's already checked return void cb(e ? e.message : 'INTERNAL_ERROR'); @@ -89,10 +90,8 @@ var makeFileStream = function (full, cb) { stream.on('open', function () { cb(void 0, stream); }); - stream.on('error', function (/* e */) { - //console.error("MAKE_FILE_STREAM", full); - // XXX ERROR - //WARN('stream error', e); + stream.on('error', function (err) { + cb(err); }); } catch (err) { cb('BAD_STREAM');