mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-18 17:33:30 -05:00
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:
1 parent
d68e5602bd
commit
5fa3f2aebe
33 files changed
+899
-1153
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+864
-1153
File diff suppressed because it is too large.
Load diff
@@ -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:
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in new issue
Block a user