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: add bytesRead to ReadStream #7942

Closed
wants to merge 1 commit into from

Conversation

LinusU
Copy link
Contributor

@LinusU LinusU commented Aug 1, 2016

Checklist
  • make -j4 test (UNIX), or vcbuild test nosign (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

fs

Description of change

Add a property named bytesRead that exposes how many bytes that have currently been read from the file. This brings consistency with WriteStream that has bytesWritten and net.Socket which have both bytesRead and bytesWritten.

Fixes #7938

@nodejs-github-bot nodejs-github-bot added the fs Issues and PRs related to the fs subsystem / file system. label Aug 1, 2016
callbacks.end++;
});


file.on('close', function() {
assert.strictEqual(file.bytesRead, bytesRead);
Copy link
Member

Choose a reason for hiding this comment

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

You could also add a line that compares file.bytesRead with the actual file size, like this:

assert.strictEqual(file.bytesRead, fs.statSync(fn).size);

@jasnell
Copy link
Member

jasnell commented Aug 1, 2016

Generally LGTM with Green CI and @addaleax's comment addressed

@jasnell jasnell added the semver-minor PRs that contain new features and should be released in the next minor version. label Aug 1, 2016
@ronkorving
Copy link
Contributor

Thank you for this, a very welcome addition. 👍

@LinusU
Copy link
Contributor Author

LinusU commented Aug 2, 2016

Addressed comment and rebased on latest master 👌

edit: How do I trigger CI? Or is that something that someone from the core team does?

@brendanashworth
Copy link
Contributor

Here you go: https://ci.nodejs.org/job/node-test-pull-request/3496/

@LinusU
Copy link
Contributor Author

LinusU commented Aug 2, 2016

Finished: SUCCESS

✅ Green CI

@jasnell
Copy link
Member

jasnell commented Aug 4, 2016

@addaleax @bnoordhuis @trevnorris ... would love to get your review on this also!

@@ -181,6 +181,13 @@ added: v0.1.93
Emitted when the `ReadStream`'s underlying file descriptor has been closed
using the `fs.close()` method.

### readStream.bytesRead
<!-- YAML
added: v6.4.0
Copy link
Member

Choose a reason for hiding this comment

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

I’d say with 99 % confidence that the version here is accurate, but ideally you can use added: REPLACEME here so that the correct version will be inserted when the release is made.

Copy link
Member

Choose a reason for hiding this comment

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

oh, good catch... yeah, using REPLACEME is likely better

@addaleax
Copy link
Member

addaleax commented Aug 4, 2016

LGTM with a comment, thanks for the work behind this!

@bnoordhuis
Copy link
Member

LGTM

Add a property named bytesRead that exposes how many bytes that have
currently been read from the file. This brings consistency with
WriteStream that has bytesWritten and net.Socket which have both
bytesRead and bytesWritten.

Fixes nodejs#7938
@LinusU
Copy link
Contributor Author

LinusU commented Aug 5, 2016

  • Switched from v6.4.0 to REAPLCEME
  • Rebased on latest master

@jasnell
Copy link
Member

jasnell commented Aug 5, 2016

Thank you for bearing with us! :-) One more CI run following the updated commits: https://ci.nodejs.org/job/node-test-pull-request/3544/

@jasnell
Copy link
Member

jasnell commented Aug 5, 2016

There was a build bot failure on freebsd... running again just to make sure it's a one off: https://ci.nodejs.org/job/node-test-pull-request/3546/

@jasnell
Copy link
Member

jasnell commented Aug 8, 2016

hmm... failed on freebsd again... one more try: https://ci.nodejs.org/job/node-test-pull-request/3572/

@jasnell
Copy link
Member

jasnell commented Aug 8, 2016

Failed on Windows this time, unrelated build bot failure tho, at least that's different from last time. getting this landed!

jasnell pushed a commit that referenced this pull request Aug 8, 2016
Add a property named bytesRead that exposes how many bytes that have
currently been read from the file. This brings consistency with
WriteStream that has bytesWritten and net.Socket which have both
bytesRead and bytesWritten.

Fixes: https://github.com/nodejs/node/issues/#7938
PR-URL: #7942
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@jasnell
Copy link
Member

jasnell commented Aug 8, 2016

Landed in 4a87abb. Thank you!

@jasnell jasnell closed this Aug 8, 2016
@cjihrig cjihrig mentioned this pull request Aug 8, 2016
@LinusU
Copy link
Contributor Author

LinusU commented Aug 9, 2016

Awesome 🎉 thank you!

@LinusU LinusU deleted the fs-read-stream-bytes-read branch August 9, 2016 08:22
cjihrig pushed a commit that referenced this pull request Aug 10, 2016
Add a property named bytesRead that exposes how many bytes that have
currently been read from the file. This brings consistency with
WriteStream that has bytesWritten and net.Socket which have both
bytesRead and bytesWritten.

Fixes: https://github.com/nodejs/node/issues/#7938
PR-URL: #7942
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@cjihrig cjihrig mentioned this pull request Aug 11, 2016
cjihrig added a commit that referenced this pull request Aug 11, 2016
Notable changes:

* build: zlib symbols and additional OpenSSL symbols are now exposed on Windows platforms. (Alex Hultman) #7983 and #7576
* child_process, cluster: Forked child processes and cluster workers now support stdio configuration. (Colin Ihrig) #7811 and #7838
* fs: fs.ReadStream now exposes the number of bytes it has read so far. (Linus Unnebäck) #7942
* repl: The REPL now supports editor mode. (Prince J Wesley) #7275
* util: inspect() can now be configured globally using util.inspect.defaultOptions. (Roman Reiss) #8013

Refs: #8020
PR-URL: #8070
cjihrig added a commit that referenced this pull request Aug 11, 2016
Notable changes:

* build: zlib symbols and additional OpenSSL symbols are now exposed on Windows platforms. (Alex Hultman) #7983 and #7576
* child_process, cluster: Forked child processes and cluster workers now support stdio configuration. (Colin Ihrig) #7811 and #7838
* child_process: argv[0] can now be set to arbitrary values in spawned processes. (Pat Pannuto) #7696
* fs: fs.ReadStream now exposes the number of bytes it has read so far. (Linus Unnebäck) #7942
* repl: The REPL now supports editor mode. (Prince J Wesley) #7275
* util: inspect() can now be configured globally using util.inspect.defaultOptions. (Roman Reiss) #8013

Refs: #8020
PR-URL: #8070
cjihrig added a commit that referenced this pull request Aug 15, 2016
Notable changes:

* build: zlib symbols and additional OpenSSL symbols are now exposed on Windows platforms. (Alex Hultman) #7983 and #7576
* child_process, cluster: Forked child processes and cluster workers now support stdio configuration. (Colin Ihrig) #7811 and #7838
* child_process: argv[0] can now be set to arbitrary values in spawned processes. (Pat Pannuto) #7696
* fs: fs.ReadStream now exposes the number of bytes it has read so far. (Linus Unnebäck) #7942
* repl: The REPL now supports editor mode. (Prince J Wesley) #7275
* util: inspect() can now be configured globally using util.inspect.defaultOptions. (Roman Reiss) #8013

Refs: #8020
PR-URL: #8070
cjihrig added a commit to cjihrig/node that referenced this pull request Aug 16, 2016
Notable changes:

* build: zlib symbols and additional OpenSSL symbols are now exposed on Windows platforms. (Alex Hultman) nodejs#7983 and nodejs#7576
* child_process, cluster: Forked child processes and cluster workers now support stdio configuration. (Colin Ihrig) nodejs#7811 and nodejs#7838
* child_process: argv[0] can now be set to arbitrary values in spawned processes. (Pat Pannuto) nodejs#7696
* fs: fs.ReadStream now exposes the number of bytes it has read so far. (Linus Unnebäck) nodejs#7942
* repl: The REPL now supports editor mode. (Prince J Wesley) nodejs#7275
* util: inspect() can now be configured globally using util.inspect.defaultOptions. (Roman Reiss) nodejs#8013

Refs: nodejs#8020
PR-URL: nodejs#8070
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. semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants