mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
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:
1 parent
ccf69dd3b6
commit
39caa6ddaf
1 file changed
+7
-7
@@ -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) => {
|
||||
|
||||
Reference in new issue
Block a user