-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
Conversation
8bcf224
to
6b436d9
Compare
callbacks.end++; | ||
}); | ||
|
||
|
||
file.on('close', function() { | ||
assert.strictEqual(file.bytesRead, bytesRead); |
There was a problem hiding this comment.
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);
Thank you for this, a very welcome addition. 👍 |
6b436d9
to
5fcd263
Compare
Addressed comment and rebased on latest master 👌 edit: How do I trigger CI? Or is that something that someone from the core team does? |
✅ Green CI |
@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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
LGTM with a comment, thanks for the work behind this! |
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
5fcd263
to
460a501
Compare
|
Thank you for bearing with us! :-) One more CI run following the updated commits: https://ci.nodejs.org/job/node-test-pull-request/3544/ |
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/ |
hmm... failed on freebsd again... one more try: https://ci.nodejs.org/job/node-test-pull-request/3572/ |
Failed on Windows this time, unrelated build bot failure tho, at least that's different from last time. getting this landed! |
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>
Landed in 4a87abb. Thank you! |
Awesome 🎉 thank you! |
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>
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
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
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
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
Checklist
make -j4 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected 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 withWriteStream
that hasbytesWritten
andnet.Socket
which have bothbytesRead
andbytesWritten
.Fixes #7938