Skip to content

Skip unreadable folders when scanning for images [patch] - #168

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/scan-skip-inaccessible-dirs
Sep 28, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/scan-skip-inaccessible-dirs

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #162

What changed

ImageScanner.ScanForImages enumerated with SearchOption.AllDirectories. That overload leaves IgnoreInaccessible off, so the first subfolder it couldn't open threw UnauthorizedAccessException and killed the whole scan before anything was described. On Windows that happens for any drive root or user-profile root, which are the usual targets.

It now enumerates with EnumerationOptions { RecurseSubdirectories = true, IgnoreInaccessible = true }. Unreadable folders are skipped and the rest of the tree is scanned.

Test

ScanForImagesSkipsUnreadableSubdirectories creates readable.jpg next to a locked/ folder with mode 000 and expects only the readable image back.

  • Run as an unprivileged user (nobody): it fails without the fix (UnauthorizedAccessException: Access to the path '.../locked' is denied) and passes with it.
  • It reports Inconclusive on Windows and when run as root, since root can read a 000 folder. GitHub's Linux runners run as a non-root user, so CI exercises it.

Full suite locally: 46 passed, 1 skipped (this test, because the local run was as root).

🤖 Generated with Claude Code

https://claude.ai/code/session_01QtRTdtw1SbV7ugjz5wPFgc


Generated by Claude Code

Directory.EnumerateFiles with SearchOption.AllDirectories throws on the
first subfolder it can't open, so a scan of a Windows drive or profile
root died before describing anything. Enumerate with IgnoreInaccessible
so those folders are skipped and the rest of the tree is scanned.

Fixes #162

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QtRTdtw1SbV7ugjz5wPFgc
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit d908f7d into main Sep 28, 2026
12 checks passed
@matt-edmondson
matt-edmondson deleted the fix/scan-skip-inaccessible-dirs branch September 28, 2026 08:58
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.

Scan crashes with an unhandled UnauthorizedAccessException, describing nothing, when any subfolder of the scanned tree is unreadable

2 participants