fix: keep the mame clone map across runs

A clone group is only visible while both copies are on disk, and the
run then deletes the clone, so writing only what this run saw erased
every mapping an earlier run had recorded. One real run took the map
from 69 entries to 1, and the canonical zips silently stopped answering
to the names they stand in for.

The map is merged now, the 68 lost entries are restored, and the one
whose canonical file is no longer in the collection is dropped.
This commit is contained in:
Abdessamad Derraz committed 2026-08-11 18:41:04 +02:00
1 parent 8c018849ae
commit 4ecb65b8d9
3 files changed
+87

No files matched your search

+15
View File
@@ -228,6 +228,21 @@ def deduplicate(bios_dir: str, dry_run: bool = False) -> dict:
# Write MAME clone mapping
if mame_clones:
clone_path = "_mame_clones.json"
# A group is only visible while both copies are on disk, and this run
# has just deleted the clone. Writing only what was seen this time
# therefore erases every mapping an earlier run recorded, and the
# canonical zip stops answering to the names it stands in for. The
# older entries stay valid: their canonical file is still here.
if not dry_run:
try:
with open(clone_path) as f:
previous = json.load(f)
except (FileNotFoundError, json.JSONDecodeError):
previous = {}
if isinstance(previous, dict):
merged = dict(previous)
merged.update(mame_clones)
mame_clones = merged
if dry_run:
print(f"\nWould write MAME clone map: {clone_path}")
print(