mixu / wildglob

9 stars 1 forks source link

permissions causes unrecovered failure; is expected? #3

Open dave-dembeck opened 8 years ago

dave-dembeck commented 8 years ago

Been using wildglob for some time; great work.

I ran into an issue today where if a recursive wildglob encounters a directory where perms are not available to the running user process, wildglob throws an error (and hence the result set it empty):

.../node_modules/wildglob/index.js:110 function(err) { throw err; }, ^

Error: EACCES: permission denied, scandir '.../model/permden/permnope/' at Error (native) at Object.fs.readdirSync (fs.js:856:18) at readdirSync (.../node_modules/wildglob/lib/fs.js:17:24) at .../node_modules/wildglob/lib/traverse.js:59:7 at statSync (.../node_modules/wildglob/lib/fs.js:12:9) at traverse (.../node_modules/wildglob/lib/traverse.js:22:3) at Glob._doStat (.../node_modules/wildglob/index.js:104:14) at .../node_modules/wildglob/lib/traverse.js:80:33 at runTaskImmediately .../node_modules/wildglob/index.js:12:37) at .../node_modules/wildglob/lib/traverse.js:80:11

Is this the intended behaviour? I would have expected wildglob to have skipped over such directories, catching the error during traversal and hence not recursing such directories.

mixu commented 8 years ago

nope, it should not error out - could you post the permissions and I'll look into it when I have a moment? I'm also happy to accept a PR :wink:

dave-dembeck commented 8 years ago

Hi Mixu, thanks for the quick reply!

So, let's say wildglob is watching /foo

setup:

cd foo mkdir permnope chmod a-rwx permnope

then when watching /foo, wildglob will throw the exception at wildglob/lib/fs.js:17, the consequence is no files are returned.

FWIW, I tested on Centos (7.2 and 6.7).

Let me know if that makes sense. Thanks for your reply! -D

dave-dembeck commented 8 years ago

As an aside, happy to provide a PR, but I will be offline next week; Can provide one the following week.