60def _write(runs: dict[str, dict]) ->
None:
61 """Replace the store atomically, so a crash or a concurrent reader never sees a
62 half-written file. Same directory as the target — os.replace is only atomic within
64 path = config.DESCRIPTIONS_PATH
65 path.parent.mkdir(parents=
True, exist_ok=
True)
66 fd, tmp = tempfile.mkstemp(dir=str(path.parent), prefix=
".descriptions-", suffix=
".tmp")
68 with os.fdopen(fd,
"w", encoding=
"utf-8")
as fh:
69 json.dump({
"version": _SCHEMA,
"runs": runs}, fh, indent=1, sort_keys=
True)