fix: stop Stats counting files it could not hash as duplicates [patch] - #142
Merged
Merged
Conversation
Stats derived "Duplicate files" from the scanned list, but HashFiles drops a file it cannot read, so each unreadable file was reported as a duplicate of nothing. The counts and the total size now come from the files that hashed, and the files that did not are reported on their own "Unreadable files" line. Fixes #137 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YLYtHwwqdY3Tk9vpkwT6Sw
|
This was referenced Sep 27, 2026
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 #137
What changed
Stats.Runworked outDuplicate filesasfiles.Count - hashGroups.Count.filesis every file the scan found.FileHasher.HashFilesdrops any file it can't read, so every unreadable file was counted as a duplicate. One unreadable file in a tree with no duplicates gaveDuplicate files: 1next toDuplicate groups: 0.Stats.csnow works from the files that were hashed:Duplicate filesisfileHashes.Count - hashGroups.Count.Total sizesumsfileHashes.Keys. This leaves out files the other statistics already skip, and a file deleted after the scan no longer throwsFileNotFoundExceptionhere.Unreadable files: Nline appears underTotal filesonly when N > 0, so output for a clean tree hasn't changed.Tests
Two new tests in
VerbOutputTests:StatsReportsAFileItCannotHashAsUnreadable: a tree with two unique files and a third held open withFileShare.None. It expects 1 unreadable file, 9 B total size and 0 duplicate files. The test holds a share lock instead of changing permissions because root reads through permissions, and .NET enforcesFileShare.Noneon every platform.StatsOmitsTheUnreadableLineWhenEveryFileHashes.With
Stats.csreverted, the first test fails. With the fix, the full suite has 48 passes and 0 failures. The other 2 tests are the existing permission-based ones, which report inconclusive when run as root.🤖 Generated with Claude Code
https://claude.ai/code/session_01YLYtHwwqdY3Tk9vpkwT6Sw
Generated by Claude Code