handle stream errors when uploading

This commit is contained in:
ansuz 2019-09-23 11:17:42 +02:00
parent 33623bdafc
commit 744be9929f
1 changed files with 4 additions and 5 deletions

View File

@ -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');