-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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: properly handle fd passed to truncate() #866
Conversation
fs.truncate(fd, 5, function(err) { | ||
assert.ok(!err); | ||
success++; | ||
}); |
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.
Suggestion: check that the file is really truncated.
LGTM with the remark that, ideally, the commit is split in two. It fixes two unrelated bugs now. |
Currently, fs.truncate() silently fails when a file descriptor is passed as the first argument. This commit changes this behavior to properly call fs.ftruncate(). PR-URL: nodejs/node-v0.x-archive#9161 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Timothy J Fontaine <tjfontaine@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Conflicts: lib/fs.js
This commit adds proper type checking to makeCallback(). Anything other than undefined or a function will throw. PR-URL: #866 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@bnoordhuis added a check that the |
return rethrow(); | ||
} | ||
|
||
if (typeof cb !== 'function') { |
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.
What's the point of an extra check? this function is internal anyway never mind
LGTM |
This commit adds proper type checking to makeCallback(). Anything other than undefined or a function will throw. PR-URL: #866 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Vladimir Kurchatkin <vladimir.kurchatkin@gmail.com>
Currently,
fs.truncate()
silently fails when a file descriptor is passed as the first argument. This commit changes this behavior to properly callfs.ftruncate()
. This commit also adds proper type checking to the callback provided tomakeCallback()
.Port of nodejs/node-v0.x-archive#9161