Skip to content
Browse files

Do chown/lchown properly, and no utimes on windows

  • Loading branch information...
1 parent 9d3c1a8 commit fbb24256c113caf665e3d9f130dde7d4ab43cdda @isaacs isaacs committed Nov 30, 2011
Showing with 13 additions and 12 deletions.
  1. +13 −12 lib/writer.js
View
25 lib/writer.js
@@ -226,23 +226,24 @@ Writer.prototype._finish = function () {
// uid, gid
// Don't even try it unless root. Too easy to EPERM.
if (process.platform !== "win32" &&
- process.getuid &&
- process.getuid() === 0 &&
- fs.chown &&
+ process.getuid && process.getuid() === 0 &&
( typeof me.props.uid === "number" ||
- typeof me.props.gid === "number")) {
- if (typeof me.props.uid !== "number") me.props.uid = current.uid
- if (typeof me.props.gid !== "number") me.props.gid = current.gid
- if (me.props.uid !== current.uid || me.props.gid !== current.gid) {
- todo ++
- // console.error(" W chown", me.props.uid, me.props.gid, me.basename)
- fs.chown(me._path, me.props.uid, me.props.gid, next("chown"))
+ typeof me.props.gid === "number" )) {
+ var chown = (me.props.follow || me.type !== "SymbolicLink")
+ ? "chown" : "lchown"
+ if (fs[chown]) {
+ if (typeof me.props.uid !== "number") me.props.uid = current.uid
+ if (typeof me.props.gid !== "number") me.props.gid = current.gid
+ if (me.props.uid !== current.uid || me.props.gid !== current.gid) {
+ todo ++
+ // console.error(" W chown", me.props.uid, me.props.gid, me.basename)
+ fs[chown](me._path, me.props.uid, me.props.gid, next("chown"))
+ }
}
}
// atime, mtime.
- if (fs.utimes &&
- !(process.platform === "win32" && me.type === "Directory")) {
+ if (fs.utimes && process.platform !== "win32") {
var utimes = (me.props.follow || me.type !== "SymbolicLink")
? "utimes" : "lutimes"

0 comments on commit fbb2425

Please sign in to comment.
Something went wrong with that request. Please try again.