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

+22
View File
@@ -98,6 +98,28 @@ class TrueDuplicates(_Bios):
self.run_dedup()
self.assertEqual(self.existing(), {"Sony/PS/scph.bin"})
def test_a_variant_under_another_name_loses_to_the_file_holding_its_bytes(self):
# .variants/scph1001.bin.649895ef held the bytes of scph1001_v20.bin:
# the content was answered twice and the index kept one at random.
self.write("Sony/PS/scph1001_v20.bin")
self.write("Sony/PS/.variants/scph1001.bin.649895ef")
self.run_dedup()
self.assertEqual(self.existing(), {"Sony/PS/scph1001_v20.bin"})
def test_two_variants_of_one_content_keep_one(self):
# msx.rom.a317e6b4 and MSX.ROM.e998f0c4 differ only by casing and
# suffix; nothing outside .variants/ holds the bytes in this tree.
self.write("Microsoft/MSX/.variants/msx.rom.a317e6b4")
self.write("Microsoft/MSX/.variants/MSX.ROM.e998f0c4")
self.run_dedup()
self.assertEqual(len(self.existing()), 1)
def test_a_variant_of_other_bytes_stays(self):
self.write("Sony/PS/scph1001.bin", b"PRIMARY")
self.write("Sony/PS/.variants/scph1001.bin.649895ef", b"ALTERNATE")
self.run_dedup()
self.assertEqual(len(self.existing()), 2)
def test_different_content_under_one_name_is_never_touched(self):
self.write("Sony/PS/a.bin", b"CONTENT ONE")
self.write("Sega/Saturn/a.bin", b"CONTENT TWO")