Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission errors don't seem to be handled. #8

Closed
OmgImAlexis opened this issue Mar 21, 2020 · 3 comments
Closed

Permission errors don't seem to be handled. #8

OmgImAlexis opened this issue Mar 21, 2020 · 3 comments

Comments

@OmgImAlexis
Copy link
Contributor

Permission errors don't seem to be handled.

import * as fdir from 'fdir';

fdir.async('/', {}).then(files => {
    console.log(files);
});
TypeError: Cannot read property 'length' of undefined
    at /Users/xo/code/r/node_modules/fdir/index.js:40:39
    at fs.js:153:23
    at FSReqCallback.req.oncomplete (fs.js:778:9)

Changing the affected line to this.

        fs.readdir(dir, readdirOpts, function(_, dirents) {
          console.log({_,dirents});
          for (var j = 0; j < dirents.length; ++j) {

I get the following.

{
  _: [Error: EACCES: permission denied, scandir '//.fseventsd'] {
    errno: -13,
    code: 'EACCES',
    syscall: 'scandir',
    path: '//.fseventsd'
  },
  dirents: undefined
}
@thecodrr
Copy link
Owner

I am on it. Thanks for reporting.

thecodrr added a commit that referenced this issue Mar 21, 2020
@OmgImAlexis
Copy link
Contributor Author

With that fix what happens if only one sub directory has a permission error but all others are fine?

@thecodrr
Copy link
Owner

It will reject, bailing out of the function. Should it simply skip over that directory? How will errors be handled then? We have two options:

  1. We save all errors in an array and at the end we reject the promise with those errors and the results.
  2. We resolve the promise but send errors with result too.

@thecodrr thecodrr reopened this Mar 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants