From 03eb97e789bb7496129415af4b77e25d43ab10a7 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 14 Dec 2015 14:40:45 -0500 Subject: [PATCH] Fix bug working on network-path files on windows (results in ENOTSUP error code instead of ENOTDIR). --- chownr.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/chownr.js b/chownr.js index df3753f..7e63928 100644 --- a/chownr.js +++ b/chownr.js @@ -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 @@ -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 }