Skip to content

Skip unreadable dirs in recursive file walk (closes #3)#76

Merged
thorwhalen merged 1 commit into
masterfrom
fix/issue3-walk-permission
Jul 5, 2026
Merged

Skip unreadable dirs in recursive file walk (closes #3)#76
thorwhalen merged 1 commit into
masterfrom
fix/issue3-walk-permission

Conversation

@thorwhalen

Copy link
Copy Markdown
Member

What

FileBytesReader(gettempdir()) (Issue #3) raised PermissionError [Errno 1] Operation not permitted because the recursive walk's paths_in_dir caught only FileNotFoundError, so os.listdir on 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.

s = FileBytesReader(gettempdir())
list(s)   # 3970 keys  (was: PermissionError)

Tests + safety

  • Deterministic regression test: a chmod 000 subdir is skipped while readable siblings are still returned (POSIX-only; skipped on Windows / when running as root).
  • Dependents test-gate (all 56 with tests): 39 pass, 0 PASS→FAIL — the 17 non-passing fail identically at baseline (pre-existing env issues). The change is robustness-only (it only alters behavior where os.listdir previously crashed).

Closes #3

https://claude.ai/code/session_01H8PmV6xmMhzV64zi1Twraw

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
@thorwhalen thorwhalen merged commit 80db4e7 into master Jul 5, 2026
12 checks passed
@thorwhalen thorwhalen deleted the fix/issue3-walk-permission branch July 5, 2026 14:25
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

Successfully merging this pull request may close these issues.

FilesBytesReader not working with tempfiles

1 participant