mirror of
https://github.com/calibrain/shelfmark.git
synced 2026-11-18 06:00:28 +00:00
In a series pack, each book's folder often holds files with the same names, such as `Book 1/001.mp3` and `Book 2/001.mp3`. After download, the files can sit under an extra folder. The reviewed plan's exact paths then miss, and the basename fallback takes the first unclaimed `001.mp3`. That file can belong to another book. `match_plan_to_files` now tries these steps in order: - Release-relative path, as before. - The same path under the release root's name, when that file is unclaimed. - The same-named file that shares the most parent folders with the planned path. It needs at least two shared parts, and a tie falls through. - Basename, then glued-name suffix, as before. Verified with `tests/download/test_packs.py`: 59 passed, including 4 new cases for duplicate names in a reversed plan, path collisions, ties and repeated root names. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Improved matching between planned release files and files on disk, including paths prefixed by the release root. Exact path matches take precedence, and ambiguous matches retain predictable ordering. * Unmatched files continue to be grouped heuristically. <!-- end of auto-generated comment: release notes by coderabbit.ai -->