fs: use _final() for fs.WriteStream

use _final() method instead of once 'finish' event.

PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Jackson Tian authored and Anna Henningsen committed 2018-05-14 19:22:08 +02:00
1 parent ccf69dd3b6
commit 39caa6ddaf
1 file changed
+7 -7
+7 -7
View File
@@ -2212,17 +2212,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) => {