Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs,stream: introduce FileSystemStream #36408

Closed
wants to merge 2 commits into from
Closed

Conversation

aduh95
Copy link
Contributor

@aduh95 aduh95 commented Dec 6, 2020

Adds a Trait (abstract class?) to group functionality of fs.ReadStream and fs.WriteStream.

Refs: #35922 (comment)

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

/cc @mmomtchev

Adds a Trait to group functionality of fs.ReadStream and fs.WriteStream.
@nodejs-github-bot nodejs-github-bot added the fs Issues and PRs related to the fs subsystem / file system. label Dec 6, 2020
@benjamingr
Copy link
Member

ping @ronag

Copy link
Member

@ronag ronag left a comment

Choose a reason for hiding this comment

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

Nothing wrong with it per se but it looks to me like unnecessary abstraction...

@mmomtchev
Copy link
Contributor

Me too, my first impression was that it was useless bloat, but now when I see it fully implemented, I must admit that it is a PR that deletes more lines than it introduces - even if most of the difference comes from removing a few large comment blocks

// stream.closed = true;
cb(err);
}
};
Copy link
Member

@ronag ronag Dec 7, 2020

Choose a reason for hiding this comment

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

This doesn't need to live on the prototype. Just make it a function taking stream as first param.

cb(er || err);
});
stream.fd = null;
function FileSystemStream(path, options) {
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't need to be a constructor function. Can be just a regular function taking stream as first param.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But it's taking the options to, well construct the (Read|Write)Stream instance (defining properties on it)…

@benjamingr
Copy link
Member

I tend to agree with Robert regarding this sort of abstraction not making the code easier - I didn't want to say that before to not influence bias but I am -0 on this (won't block but generally not in favour).

@aduh95
Copy link
Contributor Author

aduh95 commented Dec 7, 2020

I don't feel strongly about this myself, I just find the importFd function weird and IMHO it makes it hard to follow which properties are assigned on the instance. Also there is a lot of code shared by the two class constructors, I thought it would be useful to avoid code duplication.
If no one is in favour, I'm going to close this.

@aduh95 aduh95 closed this Dec 7, 2020
@aduh95 aduh95 deleted the fs-stream branch December 7, 2020 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants