Ability for @std/fs/walk to ignore or handle `PermissionDenied` errors
- Dominant language
- TypeScript
- Stars
- 3.6k
- Forks
- 681
- PR merge metrics
- No merged PRs in 30d
Description
**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'`
Contributor guide
Research direction
Start at the @std/fs/walk entry point and inspect the WalkOptions type. Run the provided walk script against a directory containing an unreadable subdirectory to reproduce the PermissionDenied error. Done means callers can choose to handle or ignore the permission error while walking continues when requested.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- deno, typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100