-
-
Notifications
You must be signed in to change notification settings - Fork 156
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
Added support for changing uid/gid (fix #157) #188
Conversation
@@ -66,6 +66,48 @@ function getTimesDiff(fsStat, vinylStat) { | |||
return timesDiff; | |||
} | |||
|
|||
function getOwnerDiff(fsStat, vinylStat) { | |||
if (/^win/.test(process.platform)) { |
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.
there should be no reason to do this. In updateMetadata
, we exit early on windows (it doesn't have process.getuid()
)
@stephanvl very nice work. I just had some suggestions and the appveyor CI is still failing. Let me know once you've had a chance to clean it up. |
@phated I removed the latter 2 commits which added the windows specific code, added a I also updated the |
}; | ||
var expected = { | ||
uid: 1001, | ||
gid: undefined, |
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.
fs.fchown throws if uid or gid is undefined. Do we need to handle this by returning undefined
if we don't have a complete diff?
@stephanvl this looks near perfect. Just 1 thing that I noticed while poking around in the node repl. Commented inline. |
@phated Good catch, I will change it to return undefined when either uid or gid is undefined as there is no way of knowing what it should be at that point. Then there is only the question what we should do about the fact that chown only works when the user is root (fail silently, throw an error or log a message and continue)? |
@stephanvl we already handle that with our |
@phated but you must be root for chown to work, being the owner of a file is not enough. |
Those errors should be bubbled up, I believe. |
graceful-fs gracefully ignores EPERM errors, which changing the owner as a non root user is https://github.com/isaacs/node-graceful-fs/blob/master/polyfills.js#L245-L249 |
👍 I'm fine with that then |
@stephanvl amazing work! Thanks a ton |
This PR adds support for changing the uid/gid of a file/directory.
Changing the uid/gid of a file is only possible as the root user and will fail silently if this run as a non root user.
What do you think we should do in this case?