Skip to content

Commit

Permalink
ignore ENOENT errors during chown
Browse files Browse the repository at this point in the history
Some files might be deleted during chownr. This commit ignore ENOENT
errors to tolerate such cases to mimic 'chown -R'.

Fixes npm/cli#496
  • Loading branch information
raymondfeng committed Jan 28, 2020
1 parent deaa058 commit e4c7b59
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion chownr.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ const chownr = (p, uid, gid, cb) => {
if (er)
return cb(errState = er)
if (-- len === 0)
return fs[LCHOWN](p, uid, gid, handleEISDIR(p, uid, gid, cb))
return fs[LCHOWN](p, uid, gid, handleEISDIR(p, uid, gid, er => {
if (er && er.code !== 'ENOENT') return cb();
cb();
}));
}

children.forEach(child => chownrKid(p, child, uid, gid, then))
Expand Down

0 comments on commit e4c7b59

Please sign in to comment.