fix: games tools write whole files, name options

The games importers wrote through fixed .part names, the new options had
no help text, and romfolders stopped on the first setup the offline cache
lacked. RetroArch's rom folder map is regenerated from its source spec
(path null, as the schema says). The installer's Python 3.8 job imports
the games tests without pyyaml, so the region rules load lazily.
This commit is contained in:
Abdessamad Derraz committed 2026-11-03 22:46:17 +01:00
1 parent af2e930d32
commit fd7dd0efe5
12 files changed
+82 -40

No files matched your search

+24
View File
@@ -7,6 +7,7 @@ it is only meaningful if the comparison ignores the hour."""
from __future__ import annotations
from collections.abc import Callable, Iterator
from typing import BinaryIO
import contextlib
import json
import os
@@ -159,6 +160,29 @@ def copy_file_atomic(source: str, path: str) -> None:
os.unlink(scratch)
raise
def copy_stream_atomic(stream: BinaryIO, path: str) -> None:
"""Stream a download into place whole or not at all.
A fixed scratch name let two runs interleave their bytes in one file of
the right size, which the rename then promoted."""
import shutil
directory = os.path.dirname(os.path.abspath(path))
handle, scratch = tempfile.mkstemp(
dir=directory, prefix=f".{os.path.basename(path)}.", suffix=".tmp"
)
try:
with os.fdopen(handle, "wb") as f:
shutil.copyfileobj(stream, f)
set_plain_mode(scratch)
os.replace(scratch, path)
except BaseException:
with contextlib.suppress(OSError):
os.unlink(scratch)
raise
def _strip_timestamps(text: str) -> str:
"""Remove known timestamp patterns for content comparison."""
result = text