Permalink
Browse files

use getCacheStat before lock, fixes nodejs/node-v0.x-archive#3821

Previous code did not handle the cache dir's permissions consistently.
If the first lock was done as sudo, the cache directory was not user
writable.
  • Loading branch information...
1 parent 365cb71 commit 7e1f7e38be2fc7addff4f0be1bd34a67cc407e24 @francoisfrisch committed with Jun 1, 2013
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/cache.js
View
@@ -1195,14 +1195,14 @@ function lockFileName (u) {
return path.resolve(npm.config.get("cache"), h + "-" + c + ".lock")
}
-var madeCache = false
+var validatedCache = false
var myLocks = {}
function lock (u, cb) {
// the cache dir needs to exist already for this.
- if (madeCache) then()
- else mkdir(npm.config.get("cache"), function (er) {
+ if (validatedCache) then()
+ else getCacheStat(function (er, cs) {
if (er) return cb(er)
@isaacs
isaacs Jun 1, 2013

Don't you still need to mkdir the cache folder?

You've found the source of the bug, but I'm not sure how this actually fixes it.

- madeCache = true
+ validatedCache = true
then()
})
function then () {

0 comments on commit 7e1f7e3

Please sign in to comment.