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

Commit 5c0e4c4

Browse files
joaocgreiszkat
authored andcommitted
cache: ignore failures replacing package.json
writeFileAtomic is not atomic in Windows, it fails if the file is being accessed concurrently. Fixes: #7885 Fixes: #9696 PR-URL: #10940 Credit: @orangemocha
1 parent 2c44d8d commit 5c0e4c4

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lib/cache.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ function afterAdd (cb) { return function (er, data) {
337337

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

342343
var done = inflight(pj, cb)
@@ -347,7 +348,7 @@ function afterAdd (cb) { return function (er, data) {
347348
if (er) return done(er)
348349
writeFileAtomic(pj, JSON.stringify(data), {chown : cs}, function (er) {
349350
if (!er) log.verbose("afterAdd", pj, "written")
350-
return done(er, data)
351+
return done(null, data)
351352
})
352353
})
353354
}}

0 commit comments

Comments
 (0)