From 9ba8b02ff145b72b1d0d355cf7f9af84d2f04d2a Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Fri, 3 Apr 2026 11:50:26 +0200 Subject: [PATCH] fix: verify functions handle flat zip extraction --- scripts/generate_pack.py | 7 ++++++- tests/test_e2e.py | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/generate_pack.py b/scripts/generate_pack.py index f4a47410..00ccf0d9 100644 --- a/scripts/generate_pack.py +++ b/scripts/generate_pack.py @@ -2432,6 +2432,11 @@ def _run_verify_packs(args): with zipfile.ZipFile(zip_path) as zf: zf.extractall(extract_dir) + # Auto-detect flat vs nested extraction + is_flat = bool(base_dest) and not os.path.isdir( + os.path.join(extract_dir, base_dest) + ) + missing = [] hash_fail = [] ok = 0 @@ -2442,7 +2447,7 @@ def _run_verify_packs(args): continue fp = ( os.path.join(extract_dir, base_dest, dest) - if base_dest + if base_dest and not is_flat else os.path.join(extract_dir, dest) ) # Case-insensitive fallback diff --git a/tests/test_e2e.py b/tests/test_e2e.py index bf797df0..e6b6604c 100644 --- a/tests/test_e2e.py +++ b/tests/test_e2e.py @@ -3383,10 +3383,17 @@ class TestE2E(unittest.TestCase): registry_path, emulators_dir=self.emulators_dir, ) + # Detect flat vs nested ZIP to build expected paths base = manifest.get("base_destination", "") + is_flat = bool(base) and not any( + n.startswith(base + "/") for n in zip_names + ) manifest_dests = set() for f in manifest["files"]: - d = f"{base}/{f['dest']}" if base else f["dest"] + if base and not is_flat: + d = f"{base}/{f['dest']}" + else: + d = f["dest"] manifest_dests.add(d) self.assertEqual(manifest_dests, zip_names)