Skip to content

Commit 3746187

Browse files
JacksonTianaddaleax
authored andcommitted
fs: use _final() for fs.WriteStream
use _final() method instead of once 'finish' event. PR-URL: #20562 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 34ca9f3 commit 3746187

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/fs.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,17 +2214,17 @@ function WriteStream(path, options) {
22142214

22152215
if (typeof this.fd !== 'number')
22162216
this.open();
2217-
2218-
// dispose on finish.
2219-
this.once('finish', function() {
2220-
if (this.autoClose) {
2221-
this.destroy();
2222-
}
2223-
});
22242217
}
22252218

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

2221+
WriteStream.prototype._final = function(callback) {
2222+
if (this.autoClose) {
2223+
this.destroy();
2224+
}
2225+
2226+
callback();
2227+
};
22282228

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

0 commit comments

Comments
 (0)