-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
fix chmod function arguments #71
Conversation
`*chmod*` functions accept only `path` and `mode`. As we were using `chownFix`, it misinterprets callback function passed to `chmod` as `gid`.
@thefourtheye there are still four failures in npm with this patch
|
@thefourtheye Note that this patch actually makes callback argument mandratory for For this to be not major, it should check if callback is being passed. |
@@ -205,6 +205,7 @@ function patchLutimes (fs) {
function chmodFix (orig) {
if (!orig) return orig
return function (target, mode, cb) {
+ if (!cb) cb = function () {}
return orig.call(fs, target, mode, function (er, res) {
if (chownErOk(er)) er = null
cb(er, res) This diff will make this a semverpatch change. I think it would likely be in the spirit of graceful-fs to "gracefully" handle the case where to callback is given. @isaacs do you consider a no-op graceful or should there be some sort of error / warning on platforms that require the callback? |
@thealphanerd Thanks. I included a fix to the problem now. PTAL. |
This patch doesn't seem offensive to me at all, but I'm not quite getting exactly what the problem is that it's addressing. Can someone provide an example program or test that shows the specific behavior that this is addressing? Is it a node core change that needs to be taken into consideration? The link to nodejs/node#7846 is a bit confusing for me to follow. |
Basically, if it's "chownFix doesn't work for chmod", well... ok... how come it was working all this time, then? Was it always broken? If so, how was it broken? I'm not trying to be difficult, I just have an excessive abundance of caution where it concerns this module, because it is so widely depended upon. Thanks for understanding :) |
@isaacs the TLDR on nodejs/node#7846 is that all As for the the
So the way it was being done before the The unfortunate side effect of this was that the callback wrapper that checks the error and wraps it in |
Oh! I see, so if the |
Thanks! Landed with a test and published to 4.1.5. |
graceful-fs had a bug fix, isaacs/node-graceful-fs#71, which would fix the problem in Node.js nodejs/node#7846
Fix bug in chmod wrapper that was tickled by recent node.js changes. (nodejs/node#7846) PR-URL: isaacs/node-graceful-fs#71 Credit: @thefourtheye Reviewed-By: @isaacs
graceful-fs had a bug fix, isaacs/node-graceful-fs#71, which would fix the problem in Node.js nodejs/node#7846 PR-URL: #13497 Credit: @thefourtheye Reviewed-By: @iarna
*chmod*
functions accept onlypath
andmode
. As we were usingchownFix
, it misinterprets callback function passed tochmod
asgid
.Possible Fix for nodejs/node#7846