Skip to content

Commit

Permalink
cache: fix Windows perms regression
Browse files Browse the repository at this point in the history
  • Loading branch information
othiym23 committed Jun 26, 2015
1 parent b72f6c8 commit 7e5da23
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/utils/correct-mkdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ module.exports = function correctMkdir (path, cb) {

function calculateOwner () {
if (!effectiveOwner) {
var uid = +process.getuid()
var gid = +process.getgid()
effectiveOwner = { uid: 0, gid: 0 }

if (uid === 0) {
if (process.env.SUDO_UID) uid = +process.env.SUDO_UID
if (process.env.SUDO_GID) gid = +process.env.SUDO_GID
}
if (process.getuid) effectiveOwner.uid = +process.getuid()
if (process.getgid) effectiveOwner.gid = +process.getgid()

effectiveOwner = { uid: uid, gid: gid }
if (effectiveOwner.uid === 0) {
if (process.env.SUDO_UID) effectiveOwner.uid = +process.env.SUDO_UID
if (process.env.SUDO_GID) effectiveOwner.gid = +process.env.SUDO_GID
}
}

return effectiveOwner
Expand All @@ -56,17 +56,17 @@ function makeDirectory (path, cb) {
log.verbose('makeDirectory', path, 'creation not in flight; initializing')
}

var owner = calculateOwner()

if (!process.getuid) {
return mkdirp(path, function (er) {
log.verbose('makeCacheDir', 'UID & GID are irrelevant on', process.platform)

stats[path] = { uid: 0, gid: 0 }
stats[path] = owner
return cb(er, stats[path])
})
}

var owner = calculateOwner()

if (owner.uid !== 0 || !process.env.HOME) {
log.silly(
'makeDirectory', path,
Expand Down

0 comments on commit 7e5da23

Please sign in to comment.