From b170ec5b4ba46da5d89e8d3da3eff1e354fc6a66 Mon Sep 17 00:00:00 2001 From: Vladislav Bolshakov Date: Fri, 5 Sep 2014 16:17:33 +0400 Subject: [PATCH 1/2] skip symlinks as /bin/chmod -R does To: wine-patches Reply-To: wine-devel --- chmodr.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/chmodr.js b/chmodr.js index 9edaa7f..613453b 100644 --- a/chmodr.js +++ b/chmodr.js @@ -18,7 +18,15 @@ function chmodr (p, mode, cb) { var len = children.length var errState = null children.forEach(function (child) { - chmodr(path.resolve(p, child), mode, then) + var path_child = path.resolve(p, child); + fs.lstat(path_child, function(er, stats) { + if (er) + return cb(er) + if (!stats.isSymbolicLink()) + chmodr(path_child, mode, then) + else + then() + }) }) function then (er) { if (errState) return @@ -39,7 +47,10 @@ function chmodrSync (p, mode) { if (!children.length) return fs.chmodSync(p, dirMode(mode)) children.forEach(function (child) { - chmodrSync(path.resolve(p, child), mode) + var path_child = path.resolve(p, child) + var stats = fs.lstatSync(path_child) + if (!stats.isSymbolicLink()) + chmodrSync(path_child, mode) }) return fs.chmodSync(p, dirMode(mode)) } -- 2.1.3