fix: drop variants whose bytes a file holds

A copy under .variants/ exists to hold a content its primary does
not. 29 held bytes another file already carried, under a second or
third identity: msx.rom and MSX.ROM variants equal to
MSX_8020-20bios.rom, naomi2.zip.da79eca4 whose suffix named the
primary's sha1 rather than its own. dedup now removes such a copy,
keeping one when only variants hold the content. The LaserActive
PAC-S10 BIOS lived only under .variants/ while RetroBat names it
without a hash; it moves beside its siblings.
This commit is contained in:
Abdessamad Derraz committed 2026-10-18 02:31:13 +02:00
1 parent d68e5602bd
commit 5fa3f2aebe
33 files changed
+899 -1153

No files matched your search

+13
View File
@@ -129,6 +129,19 @@ def _plan_group_removals(
name_paths.sort(key=path_priority)
true_dupes_to_remove.extend(name_paths[1:])
# A variant exists to hold a content its primary does not. Once another
# file holds the same bytes, the copy under .variants/ answers nothing
# the index does not already know, whatever its name or suffix: the
# resolver finds the content by hash and writes it under the name the
# destination asks for.
remaining = [p for p in paths if p not in true_dupes_to_remove]
variants = [p for p in remaining if ".variants" in Path(p).parts]
if variants:
holders = [p for p in remaining if p not in variants] or [
min(variants, key=path_priority)
]
true_dupes_to_remove.extend(p for p in variants if p not in holders)
# Different filenames, same content -need special handling
unique_names = sorted(by_name.keys())
if len(unique_names) > 1: