From 953e943d2d30ee0f77f2e80c49cd938574054ca9 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sun, 18 Oct 2026 20:41:39 +0200 Subject: [PATCH] fix: count data trees apart in emulator packs --- scripts/generate_pack.py | 15 ++++++++++----- tests/test_emulator_pack_counts.py | 4 +++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/scripts/generate_pack.py b/scripts/generate_pack.py index 85ae1477..2bd8cdf4 100644 --- a/scripts/generate_pack.py +++ b/scripts/generate_pack.py @@ -1424,6 +1424,7 @@ def generate_emulator_pack( ) total_files = 0 + data_files = 0 missing_files = [] rejected_files: list[str] = [] discrepancies: list[str] = [] @@ -1464,7 +1465,7 @@ def generate_emulator_pack( files = [ fe for fe in files if entry_serves_systems(fe, profile, system_ids) ] - if not files: + if not files and not profile.get("data_directories"): print(f" No files needed for {profile.get('emulator', emu_name)}") # Collect archives as atomic units @@ -1699,19 +1700,23 @@ def generate_emulator_pack( prefix = pack_structure.get(mode_key, "") if prefix: dd_dest = f"{prefix}/{dd_dest}" if dd_dest else prefix - total_files += _pack_data_tree( + data_files += _pack_data_tree( zf, local_cache, dd_dest, seen_destinations, seen_parents, seen_lower, packed_at, ) # Remove empty ZIP (no files packed and no missing = nothing to ship) - if total_files == 0 and not (missing_files or rejected_files or instruction_files or unsourceable_files): + if total_files + data_files == 0 and not (missing_files or rejected_files or instruction_files or unsourceable_files): os.unlink(zip_path) - # Report + # Report. The members of data trees are counted apart: verify --emulator + # counts the profile's files, and folding 3500 tree members into the + # same number made the two impossible to compare. missing_count = len(missing_files) ok_count = total_files parts = [f"{ok_count} files packed"] + if data_files: + parts.append(f"{data_files} from data directories") if missing_count: parts.append(f"{missing_count} missing") if rejected_files: @@ -1740,7 +1745,7 @@ def generate_emulator_pack( return ( zip_path - if total_files > 0 or missing_files or rejected_files or instruction_files + if total_files + data_files > 0 or missing_files or rejected_files or instruction_files or unsourceable_files else None ) diff --git a/tests/test_emulator_pack_counts.py b/tests/test_emulator_pack_counts.py index 44209d4e..13dfd616 100644 --- a/tests/test_emulator_pack_counts.py +++ b/tests/test_emulator_pack_counts.py @@ -21,9 +21,11 @@ REPO_ROOT = Path(__file__).resolve().parent.parent # kronos: an archive unit under its archive_prefix and a loose same-named file. # speccy,zesarux: the pack keeps speccy's PENTAGON.ROM and drops zesarux's # 32 KB pentagon.rom, which verify called covered. +# dinothawr, cemu: data directories, whose members the pack counted among +# "files packed" (110 against verify's 0/0, 303 against 67/68). CASES = ( "raze", "rust_dos", "hatari", "xash3d_fwgs", "catacombgl", "openjk", "sonic2013", - "kronos", "speccy,zesarux", + "kronos", "speccy,zesarux", "dinothawr", "cemu", )