Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Add autoClose=true option to fs.createWrireStream #20880 #25275

Closed
wants to merge 1 commit into from

Conversation

saquibkhan
Copy link

Adding autoClose=true/false option to fs.createWrireStream.

@@ -1760,7 +1761,11 @@ function WriteStream(path, options) {
this.open();

// dispose on finish.
this.once('finish', this.close);
this.once('finish', function(){
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space between ) and {

@saquibkhan
Copy link
Author

@cjihrig thanks for reviewing, apologies for space problems, i'll fix them and upload updated code.

@saquibkhan
Copy link
Author

@cjihrig thank you very much for comments, i did the respective code changes
make lint passed with 0 errors
test also passed with 0 errors

@saquibkhan
Copy link
Author

/cc @joyent/node-coreteam

@@ -1742,6 +1742,13 @@ function WriteStream(path, options) {
this.mode = options.hasOwnProperty('mode') ? options.mode : 438; /*=0666*/

this.start = options.hasOwnProperty('start') ? options.start : undefined;

if (options.hasOwnProperty('autoClose')) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with the lines above it, this should probably use a ternary operator.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually at first i used ternary operator but i got lint error 'line too long' something so i removed ternary.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be split across two lines.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this be fine?

this.autoClose = options.hasOwnProperty('autoClose') ?
                                  options.autoClose : true;

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it passes make lint, then yes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With make lint below code works fine

this.autoClose = options.hasOwnProperty('autoClose') ?
                       options.autoClose : true;

@saquibkhan
Copy link
Author

@cjihrig Thanks for comments, I have updated all comments. Please have a look.

@cjihrig
Copy link

cjihrig commented May 11, 2015

@saquibkhan
Copy link
Author

@cjihrig I have updated all comments. Please have a look.

@cjihrig
Copy link

cjihrig commented May 11, 2015

LGTM

cc: @joyent/node-coreteam

@misterdjules
Copy link

@cjihrig Shouldn't we land this in master instead of v0.12? See our guidelines for landing changes in patch releases:

They do not change or add any public interfaces.

EDIT: It looks like I suggested to submit the PR against v0.12, so that was my mistake, I apologize for the confusion. Landing it on master should not require any change though.

next();
});
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor style issue: unnecessary blank line.

assert(!stream.fd);
});
});
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing blank line.

@misterdjules
Copy link

@saquibkhan The commits will need to be squashed into just one commit before this can be merged.

Also, the commit message will need to be adjusted to conform to the contributing guidelines. If something in these guidelines is not clear, please join #libuv on Freenode and we'll be able to help you.

Thank you again 👍

@saquibkhan
Copy link
Author

@misterdjules Thanks You for your comments, i have updated the code. I wonder that lint doesn't run on test files , should it catch space issues in test file too :-)

@misterdjules
Copy link

@saquibkhan I don't know why make jslint explicitly leaves test files out of the files that are checked. I would think that we'd want to include them.

If you have some time to make the change to include them and see how much work it would be to fix the style for all tests, that would be very much appreciated!

@saquibkhan
Copy link
Author

@misterdjules Sure I would look into it why make jshint misses test files and also fix the issue.

@saquibkhan
Copy link
Author

@misterdjules Do we need to raise an issue for fixing make jshint test related changes?

@misterdjules
Copy link

LGTM, @jasnell @joyent/node-coreteam I would like to land this in master, would that interfere with the ongoing work in https://github.com/jasnell/node.js-convergence?

@misterdjules misterdjules added this to the 0.13.1 milestone May 12, 2015
@misterdjules misterdjules added master and removed v0.12 labels May 12, 2015
Add support to fs.createWriteStream and fs.WriteStream for an autoClose
option that behaves similarly to the autoClose option supported by
fs.createReadStream and fs.ReadStream.

When an instance of fs.WriteStream created with autoClose === true finishes,
it is not destroyed. Its underlying fd is not closed and it is the
responsibility of the user to close it.

Fixes nodejs#20880
@jasnell
Copy link
Member

jasnell commented Aug 15, 2015

@misterdjules ... sorry, I didn't see your previous ping to me on this. This would need to land over in nodejs/node master now.

@saquibkhan
Copy link
Author

@jasnell @misterdjules How this is going to land on nodejs/node? Do i need to raise a new pull request on nodejs/node ?

@misterdjules
Copy link

@saquibkhan Yes, the best way to move this forward is to submit a new PR at nodejs/node targeted to the master branch.

Thank you again!

@jasnell
Copy link
Member

jasnell commented Nov 4, 2015

+1. If the changes also need to land in v5/v4/v0.12/v0.10, please indicate so in the new PR and we can get the PR labeled and ensure things are properly backported. Feel free to cc @misterdjules and I on the PR so we can track!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants