Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
cache: ignore failures replacing package.json
Browse files Browse the repository at this point in the history
writeFileAtomic is not atomic in Windows, it fails if the file is
being accessed concurrently.

Fixes: #7885
Fixes: #9696
PR-URL: #10940
Credit: @orangemocha
Reviewed-By: @othiym23
  • Loading branch information
joaocgreis authored and iarna committed Jan 21, 2016
1 parent f44d8c9 commit e982858
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ function afterAdd (cb) {

// Save the resolved, shasum, etc. into the data so that the next
// time we load from this cached data, we have all the same info.
// Ignore if it fails.
var pj = path.join(cachedPackageRoot(data), 'package', 'package.json')

var done = inflight(pj, cb)
Expand All @@ -358,7 +359,7 @@ function afterAdd (cb) {
if (er) return done(er)
writeFileAtomic(pj, JSON.stringify(data), { chown: cs }, function (er) {
if (!er) log.verbose('afterAdd', pj, 'written')
return done(er, data)
return done(null, data)
})
})
}
Expand Down

0 comments on commit e982858

Please sign in to comment.