From 204952ccc329fcdc6f0e67f730a9e2e1e4823910 Mon Sep 17 00:00:00 2001 From: Vladislav Bolshakov Date: Thu, 20 Nov 2014 17:54:22 +0300 Subject: [PATCH 2/4] skip symlink --- chownr.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/chownr.js b/chownr.js index 598b8f8..969085d 100644 --- a/chownr.js +++ b/chownr.js @@ -14,7 +14,15 @@ function chownr (p, uid, gid, cb) { var len = children.length , errState = null children.forEach(function (child) { - chownr(path.resolve(p, child), uid, gid, then) + var path_child = path.resolve(p, child); + fs.lstat(path_child, function(er, stats) { + if (er) + return cb(er) + if (!stats.isSymbolicLink()) + chownr(path_child, uid, gid, then) + else + then() + }) }) function then (er) { if (errState) return @@ -35,7 +43,10 @@ function chownrSync (p, uid, gid) { if (!children.length) return fs.chownSync(p, uid, gid) children.forEach(function (child) { - chownrSync(path.resolve(p, child), uid, gid) + var path_child = path.resolve(p, child) + var stats = fs.lstatSync(path_child) + if (!stats.isSymbolicLink()) + chownrSync(path_child, uid, gid) }) return fs.chownSync(p, uid, gid) } -- 1.8.5.5