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

Ability for @std/fs/walk to ignore or handle PermissionDenied errors #6130

Open
rameshvenk opened this issue Oct 20, 2024 · 0 comments
Open

Comments

@rameshvenk
Copy link

Is your feature request related to a problem? Please describe.

The @std/fs/walk has an issue where if it encounters a directory that it does not have read permissions, it errors with a PermissionDenied: Permission denied (os error 13)
Describe the solution you'd like

Add another option to the WalkOptions type to be able to specify a handler which can handle this error and rethrow it or ignore it, or, an option to be able to ignore this error and continue (the first would be preferred).

Describe alternatives you've considered

An alternative is to re-write this feature using a generator function which seems to work, but since this feature is already available in the standard library, it would be useful to add an option to ignore or handle directories and files that it does not have permission to read

Test script

import { walk } from "jsr:@std/fs/walk";

try {
  for await (const dirEntry of walk("/etc/")) {
    console.log("Recursive walking:", dirEntry.name);
  }

} catch (err) {
  console.error(err);
}

Produces in my Macbook
PermissionDenied: Permission denied (os error 13): readdir '/etc/cups/certs'

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

1 participant