fix: pin ryujinx to its Gitea mirror

Gitea answers /raw/commit with an HTML proof-of-work page, so
Forgejo-family files are fetched through the API raw route.
This commit is contained in:
Abdessamad Derraz committed 2026-10-18 13:40:50 +02:00
1 parent 658c5a4959
commit 37633043db
4 files changed
+47 -11

No files matched your search

+1 -1
View File
@@ -62,7 +62,7 @@ def find_revision(
"""The newest revision whose copy of the path has this md5, and its bytes."""
wanted = md5.lower()
for sha in path_history(repo, path, cache_dir):
data = upstream._fetch(upstream.raw_url(repo, sha, path))
data = upstream._fetch(upstream.content_url(repo, sha, path))
if data is not None and hashlib.md5(data).hexdigest() == wanted:
return sha, data
return None
+22 -1
View File
@@ -51,6 +51,13 @@ _HOSTS: dict[str, tuple[str, str, str]] = {
"https://codeberg.org/api/v1",
"https://codeberg.org",
),
# The Ryujinx repository left GitHub in October 2024; this Gitea pull
# mirror kept its history up to 1.1.1402.
"git.ngram.ca": (
"forgejo",
"https://git.ngram.ca/api/v1",
"https://git.ngram.ca",
),
"git.citron-emu.org": (
"forgejo",
"https://git.citron-emu.org/api/v1",
@@ -180,6 +187,20 @@ def raw_url(repo: Repo, sha: str, path: str) -> str:
return f"{repo.raw_base}/{repo.owner}/{repo.name}/raw/commit/{sha}/{quoted}"
def content_url(repo: Repo, sha: str, path: str) -> str:
"""URL the tooling fetches one path from.
Forgejo and Gitea hosts put their web routes, /raw/commit included,
behind a proof-of-work page (git.ngram.ca answers 200 with an HTML
challenge); the API raw route is not challenged. raw_url stays the
link a reader opens.
"""
if repo.family != "forgejo":
return raw_url(repo, sha, path)
quoted = urllib.parse.quote(path)
return f"{repo.api_base}/repos/{repo.owner}/{repo.name}/raw/{quoted}?ref={sha}"
def _headers(url: str, accept_json: bool = False) -> dict[str, str]:
"""Request headers. GITHUB_TOKEN is only ever sent to GitHub."""
headers = {"User-Agent": USER_AGENT}
@@ -336,7 +357,7 @@ def fetch_file(
return None if text == ABSENT else text.splitlines()
if offline:
raise NotCachedError(f"{repo.slug}@{sha[:8]}:{path} is not in the offline cache")
text = _http_text(raw_url(repo, sha, path))
text = _http_text(content_url(repo, sha, path))
write_cache(target, ABSENT if text is None else text)
return None if text is None else text.splitlines()