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.
This commit is contained in:
Abdessamad Derraz committed 2026-11-21 10:30:13 +01:00
1 parent 526d7f09c7
commit 8a8fa71fbc
25 files changed
+708 -266

No files matched your search

@@ -13,22 +13,17 @@ target list, a Pi 3 pack carried the firmware of emulators only x86_64 builds.
from __future__ import annotations
import json
import re
import sys
from datetime import datetime, timezone
from . import BaseTargetScraper, target_cli
from ..base_scraper import fetch_bytes, fetch_text
from ..recalbox_scraper import Scraper as PlatformScraper, board_cores
from ..base_scraper import fetch_text
from ..recalbox_scraper import Scraper as PlatformScraper, board_cores, tree_listing
PLATFORM_NAME = "recalbox"
CONFIGS_TREE_URL = (
"https://gitlab.com/api/v4/projects/recalbox%2Frecalbox/repository/tree"
"?path=configs&ref={tag}&per_page=100"
)
DEFCONFIG_URL = "https://gitlab.com/recalbox/recalbox/-/raw/{tag}/configs/{name}"
_DEFCONFIG_RE = re.compile(r"^recalbox-(\w+)_defconfig$")
_ENABLED_RE = re.compile(r"^(BR2_PACKAGE_\w+)=y\s*$", re.MULTILINE)
@@ -57,10 +52,9 @@ class Scraper(BaseTargetScraper):
def fetch_targets(self) -> dict:
tag = self.pinned_revision(PLATFORM_NAME)
platform = PlatformScraper(tag)
listing = json.loads(fetch_bytes(CONFIGS_TREE_URL.format(tag=tag)))
boards = {
match.group(1): item["name"]
for item in listing
for item in tree_listing("configs", tag)
if (match := _DEFCONFIG_RE.match(item.get("name", "")))
}
if not boards: