fix: hold the data trees inside build_export

This commit is contained in:
Abdessamad Derraz committed 2026-11-23 21:02:46 +01:00
1 parent 5271984e8e
commit 6451ea13b4
4 files changed
+95 -24

No files matched your search

+9 -17
View File
@@ -16,7 +16,6 @@ Usage:
from __future__ import annotations
import argparse
import contextlib
import sys
from pathlib import Path
@@ -27,8 +26,6 @@ from core.paths import TRUTH_DIR
from exporter.originals import DEFAULT_CACHE
from exporter.runner import run
from model.cliargs import platform_arg, selected_platforms
from model.registry import load_data_dir_registry
from packs.datadirs import hold_data_dirs
def main() -> None:
@@ -69,20 +66,15 @@ def main() -> None:
platforms = selected_platforms(args)
with contextlib.ExitStack() as held:
if not args.refresh_cache:
# Removal candidates are proved against data/: a refresh swapping
# a tree mid-walk listed entries only that tree holds as removable.
hold_data_dirs(held, load_data_dir_registry(args.platforms_dir))
code = run(
platforms,
args.truth_dir,
args.output_dir,
args.platforms_dir,
args.upstream_dir,
args.fetch,
args.refresh_cache,
)
code = run(
platforms,
args.truth_dir,
args.output_dir,
args.platforms_dir,
args.upstream_dir,
args.fetch,
args.refresh_cache,
)
sys.exit(code)
+12 -6
View File
@@ -5,6 +5,7 @@ file from the platform's original, and a report lists every change."""
from __future__ import annotations
import contextlib
import functools
import json
from dataclasses import dataclass, field
@@ -26,6 +27,7 @@ from model.platforms import load_platform_config, native_layer
from model.profiles import load_emulator_profiles
from model.registry import load_data_dir_registry, load_platform_registry
from model.safeparse import yaml_load
from packs.datadirs import hold_data_dirs
from resolve.categories import removal_candidates
from resolve.reconcile import Report, build_native_model
from resolve.truth import generate_platform_truth
@@ -256,12 +258,16 @@ def build_export(
summary = _landed_summary(counts)
withheld = exporter.withheld()
unwritten = _unwritten(refused, withheld, report)
# Reported, never removed: the platform's file keeps every entry.
candidates = removal_candidates(
systems, scraped, profiles, load_data_dir_registry(platforms_dir),
)
# Reported, never rewritten: both declarations stay as the platform wrote them.
doubled = doubled_in(scraped, platforms_dir)
data_registry = load_data_dir_registry(platforms_dir)
with contextlib.ExitStack() as held:
# Both are proved against data/: a refresh swapping a tree mid-walk
# listed entries only that tree holds as removable. Held here, every
# caller gets the guarantee, the freshness check included.
hold_data_dirs(held, data_registry)
# Reported, never removed: the platform's file keeps every entry.
candidates = removal_candidates(systems, scraped, profiles, data_registry)
# Reported, never rewritten: both declarations stay as the platform wrote them.
doubled = doubled_in(scraped, platforms_dir)
messages = _export_messages(summary, unwritten, candidates, doubled, withheld, changes)
return ExportResult(platform, True, messages, produced, exporter.file_modes(), {