Commit Graph
47 Commits
Author SHA1 Message Date
Abdessamad Derraz 91e385598e fix: say why a version page or check went unread 2026-11-21 19:50:33 +01:00
Abdessamad Derraz 036a6ebf29 refactor: reuse the shared helpers left copied
Copies of helpers the first pass created, replaced by the helper:
- source_yaml_file for our YAML sources (generate_db read them in the
  locale's encoding, a syntax error named no file);
- data_dir_registry_at in registry_bundles, platform_registry_at (new,
  beside load_platform_registry) in the manifest;
- DATA_DIRS_FILE for the registry path five modules spelled;
- load_optional_database, sha1_at, VERSIONS_FILE, installer_module;
- DerivedView where a cache was keyed by id() of a dict;
- count_text and series where a plural or a list was written by hand.
2026-11-21 10:31:29 +01:00
Abdessamad Derraz 32a4ca1fa1 fix: read .variants archives as archives
A .variants copy is named set.zip.<md5 prefix>, and five checks of a
collection path tested endswith(".zip"): the zipped_file contents index
skipped all 278 copies (658 member md5s held nowhere else), the pack added
them without the member CRC test, and the archive acceptance count gave
them -1. They now use is_archive_path. In the index a member a primary
archive holds answers with the primary, as the resolver prefers it.
2026-11-21 10:31:11 +01:00
Abdessamad Derraz 74fcdd2bc5 refactor: read archive members in one place
core.ziptools.zip_members lists the name, size and crc32 of each member once per archive revision. The site lookup and cards, the gap report, the pack check, the romset importer, the recipe identification and build, provenance, derivations and the atom pool read it instead of opening each archive again.

Each reader also tested a .zip suffix and skipped the .variants/ copies (x.zip.1a2b3c4d): the site lookup listed no member of a copy, the gap report's member index never saw one, the pack check never compared a copy's members, and the pack builders copied a copy without its CRC test. They now use is_archive_path. The inner ROM index of the resolver reads copies too, and a copy answers only for a member no primary holds.
2026-11-21 10:30:40 +01:00
Abdessamad Derraz 8a8fa71fbc refactor: route network access through upstream
Branch heads (scrapers, FBNeo import, data directories) resolve through
core.upstream.resolve_head, with cache_dir=None to keep nothing under
.cache/upstream. Streaming downloads (large files, external pack files,
data directory archives, scraper downloads, standalone probe) go through
one core.upstream.download: scratch then rename, size cap, retries of a
cut stream, a 5xx or a rate limit. The shared rate limit wait reads
GoatCounter's X-Rate-Limit-Reset, so site insights, download.py,
indexnow and the contributor list use the same retrying client.

list_gitlinks raises TruncatedListingError on a partial tree, read
from one tree walk shared with list_tree (Forgejo paging included).
The Recalbox configs/ listing is paged with the shared page cap.
2026-11-21 10:30:13 +01:00
Abdessamad Derraz 02969dda06 refactor: read declared hashes with one helper
core.hashing.declared_hash_lists gives an entry's declared values per
field in the order written, and declared_hashes builds its sets on it.
The gap page, the doubled-destination report and the file lookup used
their own copies of that reader. The wanted page keeps its filters on
top of it. sitegen.lookup.hash_pairs replaces sorted_hash_values for
the lookup, the data exports and the structured data. The one-field
aliases parse_md5_list and reconcile.hash_values are gone, and
model.profiles reads HASH_FIELDS instead of a fourth tuple.
2026-11-21 10:29:37 +01:00
Abdessamad Derraz ed19ae4198 fix: accept only registered platforms
require_platform checks the registry instead of any platforms/<name>.yml:
verify --platform _shared reported 0/0 present and exited 0. --all and
--platform resolve through model.cliargs.selected_platforms in auto_fetch,
generate_truth, diff_truth, export_native and verify. The truth directory
is core.paths.TRUTH_DIR for its writer and its three readers, and the
remaining literal database and profile paths read core.paths and
add_repo_inputs.
2026-11-21 06:04:31 +01:00
Abdessamad Derraz 77ba6868a0 refactor: count nouns through core.text 2026-11-21 06:03:21 +01:00
Abdessamad Derraz b9441c545d fix: read variant zip copies as archives 2026-11-21 06:02:28 +01:00
Abdessamad Derraz d3d82dd296 fix: resolve the --changed base in one place 2026-11-21 06:02:11 +01:00
Abdessamad Derraz eebe6a66c3 refactor: one torrentzip comment test for capture 2026-11-21 06:02:01 +01:00
Abdessamad Derraz fd0f6c7798 refactor: share the git blob check of downloads 2026-11-21 06:02:01 +01:00
Abdessamad Derraz e462b03848 fix: compare declared hashes in one place 2026-11-21 06:01:30 +01:00
Abdessamad Derraz 39e6d57fcb refactor: walk gitlab trees in one place
core.upstream.gitlab_tree_entries serves _gitlab_tree, list_gitlinks
and the romfolders listing. The Recalbox systems listing becomes
Scraper.system_folders, so the targets scraper gets the page cap and
refuses an empty listing instead of writing boards without cores.
2026-11-21 06:00:53 +01:00
Abdessamad Derraz 8bc497cf15 fix: check zip member paths with core.ziptools
The data directory refresh dropped any name containing .. in silence,
wrote a backslash as a filename character and let a drive letter or a
backslash traversal through. The pack integrity check flagged Read..me
as a traversal. Both now use safe_member_parts, and an unsafe member
fails the refresh of its key instead of thinning the tree.
2026-11-21 06:00:53 +01:00
Abdessamad Derraz 95ed63a3f3 refactor: one etag probe for buildbot and refresh
The buildbot check now waits 30 s like the refresh, not 15.
2026-11-21 06:00:31 +01:00
Abdessamad Derraz 85f60ec525 refactor: build path commit listings in core 2026-11-21 06:00:20 +01:00
Abdessamad Derraz fdd7595a71 refactor: one retrying fetch loop in core.upstream
fetch_bytes and fetch_body now share open_retrying and read_limited:
scrapers retry a 500 or a dropped connection like profile_sync, and
fetch_body caps the body it reads.
2026-11-21 06:00:20 +01:00
Abdessamad Derraz 75b5fb987e fix: check zipped pack members like the builder 2026-11-21 06:00:14 +01:00
Abdessamad Derraz 434d660647 refactor: route atomic writes through one helper 2026-11-21 06:00:14 +01:00
Abdessamad Derraz 856883f690 refactor: share file key and member size bound 2026-11-21 05:59:58 +01:00
Abdessamad Derraz b5cfa9179f refactor: drop the unused deterministic zip writer 2026-11-21 05:59:58 +01:00
Abdessamad Derraz 3fa2f77722 refactor: share one timestamp key table 2026-11-21 05:59:58 +01:00
Abdessamad Derraz eef13547e1 refactor: share one derived-view cache 2026-11-21 05:59:51 +01:00
Abdessamad Derraz 2f8f78b6b5 refactor: one git runner and main line fallback
core.gitclone gains required_git_lines, which raises GitRefused with
git's error, and fallback_lines, the remote lines tried when no remote
names the project. profile_sync and validate_pr use both.

profile_sync --changed without --base now also finds a clone whose main
line is upstream/master, upstream/v2, origin/master or origin/v2, as
validate_pr already did, before falling back to HEAD.
2026-11-20 20:03:26 +01:00
Abdessamad Derraz ab0805e6cb refactor: print sizes with one function
core.sizes.size_text replaces readme format_size, release record
size_text, render fmt_size, the large-files notes _mib and the handheld
_size. It prints one decimal in the largest unit reached, as the site
and the installer already did.

The README download table, the release notes and the large-files page
now say 29.2 MB where they said 29 MB, a handheld archive says 85.3 KB
where it said 85 KB, and a large-files asset under 1 MB is given in KB.
2026-11-20 20:03:26 +01:00
Abdessamad Derraz 1c978f3083 refactor: fold destinations with one rule
comparable_destination moves to core.paths. Placed, placement_block,
the shared group merge of model.platforms and LauncherPlace.fold read it
in place of their own lower(). It also trims surrounding blanks and
slashes and folds with casefold: no destination, collection path or
launcher name differs under those rules today, so the output is the
same.
2026-11-20 20:03:26 +01:00
Abdessamad Derraz cc85999e22 refactor: read zip member crcs in one place
core.ziptools.readable_zip_member_crcs answers None for a file that is
no readable archive, and zip_member_crcs reads it as empty. The covering
archive choice of resolve.packfiles uses it in place of its own reader,
so it still gives up on an unreadable candidate and now shares the cache.
No behavior change.
2026-11-20 20:03:26 +01:00
Abdessamad Derraz facebef9e5 refactor: index source lines once per file
core.lines.LineIndex answers the line of an offset by binary search.
mame_parser and fbneo_parser counted the newlines before each match,
O(n) per set, and csharp_source kept its own copy of the index.

arcade_parent_importer reads a profile's repository slug through
core.upstream.parse_repo and refuses a source that is not on GitHub,
the only forge its fetches reach.
2026-11-20 20:03:20 +01:00
Abdessamad Derraz f61c2cb7d4 refactor: one network layer for the scrapers
Each network job had several copies. One is kept per job and
every caller uses it.

- Source revision: model.sourcerevision (source_revision, required_revision,
  platform_revision) replaces BaseTargetScraper's pattern list, the
  exporter's _REVISION, the four launcher_revision copies and RetroBat's
  own YAML reader. It reads the union of the shapes: GitHub raw, blob and
  tree with or without a path after the revision, GitLab raw, blob, tree
  and archive, codeload tar.gz and zip. The target scrapers now answer
  for RetroDECK, NextUI, MinUI and MyMinUI, whose tree URLs end at the
  commit, and the exporter reads GitLab blob and tree and codeload zip.
  EmuDeck and RetroBat still require a 40-hex commit, and each launcher
  reader requires its own repository in the URL.
- Latest release: fetch_github_latest_version, type-checked, is the only
  lookup. mame_hash_scraper, romset_dat_importer and the Lakka target
  scraper call it. romset_dat_importer's NoReleaseError is gone: a
  release without a tag raises RuntimeError.
- Tree listing: github_tree and tree_entries refuse a truncated or
  unreadable listing. The libretro and core-info scrapers share
  core_info_files and fetch_info_file, with libretro's refusal of an empty
  listing. The core-info listing and the RetroDECK, ROCKNIX launcher and
  libretro listings were not checked for truncation before.
- GET: fetch_bytes is the one request path. fetch_text, fetch_present
  (None on 404 only), github_json and download are built on it, so every
  read retries 429 and 5xx, caps the body and raises FetchError, a
  ConnectionError carrying the HTTP status. The target scrapers' own
  fetch_text raised RuntimeError: they now raise FetchError, and an
  optional Batocera board include is skipped on 404 only, not on any
  failure. The exporter's originals, MiSTer, RetroPie, redump and the
  buildbot index go through it too.
- Headers: core.upstream.forge_headers is the one builder. The token goes
  to api.github.com and raw.githubusercontent.com, the host compared
  whole, as Bearer. A URL that only names api.github.com in its query
  got the scrapers' token before, and profile_sync sent its token to
  github.com, whose release downloads redirect to asset storage with the
  header. Scraper reads of raw files now carry the token.
- Submodule commit: submodule_commit checks that the path is a
  submodule. Batocera's target scraper accepted any contents answer with
  a sha, a directory's tree sha included.
- Download: download streams through a scratch file renamed into place,
  retries like fetch_bytes, can keep an existing file and returns the
  Content-Disposition. It replaces the _download of romset_dat_importer
  and game_dat_importer.
2026-11-20 20:02:15 +01:00
Abdessamad Derraz cf03dcb2ef refactor: share CLI options and default paths
core.paths holds the default database, platforms, emulators and bios paths, core.cli declares the options built on them (add_repo_inputs) and the --emulator/--system modes verify and generate_pack share. model.targets.target_scope answers --target for a command line, model.profiles.no_profile_for_systems the system with no emulator. tests/sources.declared_options reads the options a script declares through either form.
2026-11-20 18:28:46 +01:00
Abdessamad Derraz 348d5b51c3 refactor: read hashes and the registry one way
Hash fields go through core.hashing.parse_hash_list, which also splits comma-joined list items: the truth model compared a comma-joined sha256 list as one value. _registry.yml goes through load_platform_registry (required= where an absent file must stop the run), database.json through load_database, file and member digests through file_digest and stream_hashes. download.py and check_release read SHA256SUMS.txt with one parser: a sha256sum -b line matched nothing in download.py and the pack went unchecked.
2026-11-20 18:28:40 +01:00
Abdessamad Derraz 3853ca2f1c refactor: public names for cross-module reads 2026-11-18 22:59:51 +01:00
Abdessamad Derraz 2c8a9cfad8 refactor: one digest loop for files and streams 2026-11-18 21:42:28 +01:00
Abdessamad Derraz cacd290d2e refactor: one digest and one lock name for probes 2026-11-18 20:38:29 +01:00
Abdessamad Derraz fdb7b6f912 refactor: host lock and measurement records go low 2026-11-18 20:37:33 +01:00
Abdessamad Derraz 3bfd72ba7f refactor: name the recipe package romrecipes 2026-11-18 20:20:46 +01:00
Abdessamad Derraz b0b505dc94 refactor: one recipe rule, one reconstruction 2026-11-18 19:58:21 +01:00
Abdessamad Derraz 29f5c48a2c refactor: system names and guides below packs 2026-11-18 19:31:27 +01:00
Abdessamad Derraz 825c527d11 refactor: one reader of a declared destination 2026-11-18 13:47:56 +01:00
Abdessamad Derraz b4573d310b refactor: one keyword-option guard in core 2026-11-18 13:47:56 +01:00
Abdessamad Derraz 0b532366d0 refactor: move pack library code into packs/ 2026-11-18 13:47:31 +01:00
Abdessamad Derraz e1f2f8685d refactor: move upstream, sourceref, version_basis
upstream reads forges with the standard library alone and scrapers,
packs and the site read it: it goes to core. sourceref is the grammar
of a profile field, which the site parses without the comparison
tool: it goes to model. version_basis is read by profile_sync alone
and opens the profiling package.
2026-11-18 12:39:09 +01:00
Abdessamad Derraz 8cdda10393 docs: say what core and resolve.layout hold 2026-11-18 12:10:12 +01:00
Abdessamad Derraz c764d9abf1 refactor: split the leaf modules libraries use
model.region holds the region vocabulary, resolve.regions the selection
that needs the cores a platform runs. The libraries behind identity.py,
retired_files.py and torrentzip.py move to resolve.identity,
model.retired and core.torrentzip, with their long docstrings; the
commands stay where they are run from. The source_ref parts that cite a
config or feature file move from scraper.shell_launchers to
resolve.launcherrefs, so resolve no longer imports the scraper package.
2026-11-18 11:39:47 +01:00
Abdessamad Derraz 83cfa6fd0f refactor: split common.py into three packages
core: cli (run_cli, input errors, name hints), github (token), paths.
model: sources, database, composition, registry, platforms,
declarations, targets, systems, profiles, cliargs. resolve: content,
ownership, datadirs, archives, localfile, directories, layout,
contentlayout, standalone, grouping, cores.

Definitions move verbatim; common.py and its re-exports are gone and
every importer, patch target and code-in-string names the new home. A
test that stubbed common.load_platform_config stubs each module that
reads the loader by its own name.
2026-11-18 11:09:13 +01:00
Abdessamad Derraz c784aef883 refactor: move leaf modules into packages
core: hashing, artifacts, ziptools, deterministic_zip, romdir, sect233r1,
crypto_verify, paths (REPO_ROOT). model: safeparse (needs yaml),
dumpcatalog, largefiles, alternatives. resolve: nativemode, validation,
launchers, slot, truth, gamedata, and exporter/baseline.py and
exporter/candidates.py as resolve/reconcile.py and resolve/categories.py,
which truth and gamedata read.

Every importer follows. Modules one level deeper read the repository
root from core.paths instead of __file__.
2026-11-18 10:50:45 +01:00