Fix: one case-duplicate path collapses the entire unmapped page to per-file units - #57
Open
sebclark wants to merge 2 commits into
Open
Fix: one case-duplicate path collapses the entire unmapped page to per-file units#57sebclark wants to merge 2 commits into
sebclark wants to merge 2 commits into
Conversation
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.
The bug
If a library contains two catalogued files whose paths differ only by casing (easily produced by sync tools or case-insensitive mounts renaming a folder's case, which leaves both spellings behind),
BookImportUnitGroupingService.BuildUnmappedUnitsthrows:because
poolFiles.ToDictionary(file => file.Path, StringComparer.OrdinalIgnoreCase)requires case-insensitively-unique paths. The controller's safety net then degrades the entire unmapped page to per-file units — grouping, group selection, and the group counts all silently break for every file, not just the offending pair (observed live: the header pill showing a book-group count within a few dozen of the raw file count on a large library, with folder grouping gone).Fix
Build the lookup with
GroupBy(..., OrdinalIgnoreCase)keeping the first file per case-folded path, so a handful of degenerate rows can't take down grouping for everyone. The duplicate file itself simply falls back to its own per-file unit, which is the existing behaviour for anything outside a built unit.Tests
case_only_duplicate_paths_should_not_break_unit_grouping— written first against unpatched develop, where it fails with the exactArgumentExceptionabove; passes with the fix