Repository navigation
Count a hardlinked file once in Stats [patch] - #191
Merged
Merged
Conversation
Stats took its headline numbers from the uncollapsed hash results, so a file and its hardlink showed as one duplicate file that Scan, DryRun and Deduplicate never act on, and the file's size was counted once per path. Duplicate files now comes from the collapsed groups, as the extension breakdown already did, and total size counts each file once. The extra paths are reported on their own line. Fixes #189 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0198HLiVUinCNr1rdcUTMQee
|
3 tasks
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 #189
What changed
Stats took its headline numbers from the uncollapsed
FileHashes/HashGroups, so a file and its hardlink showed up as a duplicate file that Scan, DryRun and Deduplicate never act on. The file's size was also counted once per path.Duplicate filesnow comes from the collapsed, deletable groups (Sum(g => g.Files.Count - 1)), as the extension breakdown already did. That also makes theemptyCopiessubtraction unnecessary.Total sizesizes each hashed file once, collapsing paths withDeduplicator.CollapseSameFile, which is nowinternal.Extra paths to the same file (counted once): N, appears when there are any, soTotal files(which still counts paths) can be reconciled.With the issue's reproduction (
a.txt, a hardlinkb.txt, and a uniquec.txt), Stats now reportsTotal size: 23 BandDuplicate files: 0.Tests
I added two tests to
SameFileTests.cs:StatsCountsAFileAndItsHardlinkAsOneFile: a file plus its hardlink gives no duplicate, and its size is counted once.StatsAgreesWithDryRunForACopyAndAHardlinkPair: a copy plus a hardlink pair givesDuplicate files: 1, which matches the.binbreakdown and DryRun'sFiles to delete: 1.Both tests fail with the fix reverted and pass with it. The full suite passes: 106 passed, 3 skipped. The 3 skips are the permission tests that can't be staged as root.
#190 (deleting one name of a hardlinked non-keeper) has the same root cause but changes deletion policy, so it gets its own PR.
Generated by Claude Code