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:
parent
34ca9f3b91
commit
37461878d0
14
lib/fs.js
14
lib/fs.js
@ -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) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user