Skip to content

Commit

Permalink
Handle errors from fsWriteStreamAtomic
Browse files Browse the repository at this point in the history
  • Loading branch information
kevva committed Mar 26, 2015
1 parent 7aea27e commit 71e5979
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ exports.save = function (streams, cb) {

var dest = path.join(this.dest(), stream.filename);
var write = fsWriteStreamAtomic(dest);
var pipe = stream.pipe(write);

files.push(write.__atomicTmp);

Expand All @@ -118,10 +117,12 @@ exports.save = function (streams, cb) {
end(next.bind(null, err));
});

pipe.on('finish', next);
pipe.on('error', function (err) {
write.on('finish', next);
write.on('error', function (err) {
end(next.bind(null, err));
});

stream.pipe(write);
}.bind(this));
}.bind(this), function (err) {
if (err) {
Expand Down

0 comments on commit 71e5979

Please sign in to comment.