Skip to content

Commit

Permalink
Fix bug working on network-path files on windows
Browse files Browse the repository at this point in the history
(results in ENOTSUP error code instead of ENOTDIR).
  • Loading branch information
rocketmonkeys authored and isaacs committed Sep 16, 2018
1 parent 76c21fa commit 03eb97e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions chownr.js
Expand Up @@ -37,9 +37,10 @@ const chownrKid = (p, child, uid, gid, cb) => {

const chownr = (p, uid, gid, cb) => {
readdir(p, { withFileTypes: true }, (er, children) => {
// any error other than ENOTDIR means it's not readable, or
// doesn't exist. give up.
if (er && er.code !== 'ENOTDIR') return cb(er)
// any error other than ENOTDIR or ENOTSUP means it's not readable,
// or doesn't exist. give up.
if (er && er.code !== 'ENOTDIR' && er.code !== 'ENOTSUP')
return cb(er)
if (er || !children.length) return fs[LCHOWN](p, uid, gid, cb)

let len = children.length
Expand Down Expand Up @@ -72,7 +73,8 @@ const chownrSync = (p, uid, gid) => {
try {
children = readdirSync(p, { withFileTypes: true })
} catch (er) {
if (er && er.code === 'ENOTDIR') return fs[LCHOWNSYNC](p, uid, gid)
if (er && er.code === 'ENOTDIR' && er.code !== 'ENOTSUP')
return fs[LCHOWNSYNC](p, uid, gid)
throw er
}

Expand Down

0 comments on commit 03eb97e

Please sign in to comment.