Skip to content

Commit

Permalink
fs: use _final() for fs.WriteStream
Browse files Browse the repository at this point in the history
use _final() method instead of once 'finish' event.

PR-URL: #20562
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
JacksonTian authored and addaleax committed May 14, 2018
1 parent 34ca9f3 commit 3746187
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2214,17 +2214,17 @@ function WriteStream(path, options) {

if (typeof this.fd !== 'number')
this.open();

// dispose on finish.
this.once('finish', function() {
if (this.autoClose) {
this.destroy();
}
});
}

fs.FileWriteStream = fs.WriteStream; // support the legacy name

WriteStream.prototype._final = function(callback) {
if (this.autoClose) {
this.destroy();
}

callback();
};

WriteStream.prototype.open = function() {
fs.open(this.path, this.flags, this.mode, (er, fd) => {
Expand Down

0 comments on commit 3746187

Please sign in to comment.