Repository navigation
Report a file passed as the root instead of crashing [patch] - #166
Merged
Merged
Conversation
FileScanner.ScanForFiles guarded with path.Exists, which is also true for a file, so Directory.EnumerateFiles threw an unhandled DirectoryNotFoundException from every verb. A file path now prints "Not a directory: ..." and the scan returns nothing, as a missing directory already did. Fixes #162 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q5ZFyLG9PgeKn5RpzhWEUQ
|
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.



Fixes #162
What changed
FileScanner.ScanForFilesguarded withpath.Exists. That is also true for a regular file, so the file path reachedDirectory.EnumerateFiles, which threw an unhandledDirectoryNotFoundException. All four verbs crashed with a stack trace.The guard now checks two things:
File.Exists: printsNot a directory: <path>and returns an empty list.Directory.Exists: keeps the existingDirectory not found: <path>message.The exit code is still 0. That is tracked separately in #144.
Tests
FileScannerAndHasherTests.ScanOfAFileReturnsNothing:ScanForFilesgiven a file path returns an empty list and does not throw.VerbOutputTests.EveryVerbReportsAFilePathAsNotADirectory: Scan, DryRun, Stats and Deduplicate (answeredy) each print the one-line error, and the file is left in place.With the
FileScanner.cschange reverted, both tests fail with the original exception. With it, the full suite passes: 61 passed, 2 pre-existing skips. I also ran the built dll against a file path and got the one-line error with no stack trace.🤖 Generated with Claude Code
https://claude.ai/code/session_01Q5ZFyLG9PgeKn5RpzhWEUQ
Generated by Claude Code