Skip unreadable dirs in recursive file walk (closes #3)#76
Merged
Conversation
paths_in_dir caught only FileNotFoundError, so os.listdir on an OS-protected directory (e.g. macOS's .../com.apple.*/TemporaryItems/ under the temp dir) raised PermissionError and crashed the whole recursive walk. This made FileBytesReader(gettempdir()) / DirReader(gettempdir()) unusable. Extend the caught set to (FileNotFoundError, NotADirectoryError, PermissionError) so the walk skips directories it can't read/list instead of crashing. - Verified: FileBytesReader(gettempdir()) now lists (was PermissionError). - Regression test: an unreadable (chmod 000) subdir is skipped, readable siblings are still returned (POSIX-only; guarded/skipped on Windows and when running as root). - Dependents test-gate: 39/56 pass, 0 PASS->FAIL (same 17 pre-existing env failures). Closes #3 Claude-Session: https://claude.ai/code/session_01H8PmV6xmMhzV64zi1Twraw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
FileBytesReader(gettempdir())(Issue #3) raisedPermissionError [Errno 1] Operation not permittedbecause the recursive walk'spaths_in_dircaught onlyFileNotFoundError, soos.listdiron an OS-protected subdir (macOS's.../com.apple.*/TemporaryItems/) crashed the whole walk.Fix
Extend the caught set to
(FileNotFoundError, NotADirectoryError, PermissionError)— skip directories that vanished, aren't directories, or aren't readable, instead of crashing.Tests + safety
chmod 000subdir is skipped while readable siblings are still returned (POSIX-only; skipped on Windows / when running as root).os.listdirpreviously crashed).Closes #3
https://claude.ai/code/session_01H8PmV6xmMhzV64zi1Twraw