mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-06 01:53:56 -06:00
fix: say why the games index did not download
This commit is contained in:
1 parent
0c384e0446
commit
f78da21656
5 files changed
+27
-13
No files matched your search
+1
-1
@@ -16,7 +16,7 @@
|
||||
# and Invoke-WebRequest throws on a cut transfer before the hash is read:
|
||||
# the site's build rewrites this line there (scripts/sitebootstrap.py).
|
||||
$mismatchAdvice = "The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that."
|
||||
$defaultInstallSha256 = "627e9c3bb72daacae022a93f5ca2ba010cd8fb025ef92d69f020734575ee9bad"
|
||||
$defaultInstallSha256 = "7cbbbe3baefc4a03f5e8a85ee915df4ae23217d21aa61a2dcfccb4cbc846f546"
|
||||
$maximumInstallerBytes = 2MB
|
||||
$installerExit = 0
|
||||
$installer = if ($PSScriptRoot) { Join-Path $PSScriptRoot "install.py" } else { $null }
|
||||
|
||||
+4
-3
@@ -9233,6 +9233,7 @@ class GamesData:
|
||||
raw = _read_capped(beside / "index.json", MAX_GAMES_INDEX_BYTES)
|
||||
cached = self.cached("index.json")
|
||||
reason = "offline"
|
||||
failure = ""
|
||||
if raw is None and network:
|
||||
try:
|
||||
raw = _fetch_json(GAMES_URL.format(path="index.json"), MAX_GAMES_INDEX_BYTES,
|
||||
@@ -9242,8 +9243,7 @@ class GamesData:
|
||||
except (urllib.error.URLError, OSError, ValueError,
|
||||
http.client.HTTPException) as exc:
|
||||
reason = "network"
|
||||
if os.environ.get("RETROBIOS_DEBUG"):
|
||||
print(f" Games index: {exc}", file=sys.stderr)
|
||||
failure = str(exc)
|
||||
else:
|
||||
if cached is not None:
|
||||
_cache_write(cached, raw)
|
||||
@@ -9252,7 +9252,8 @@ class GamesData:
|
||||
if raw is None:
|
||||
raise GamesUnavailable(reason, (
|
||||
f"the games index is not on this machine and {offline_words()}"
|
||||
if reason == "offline" else "the games index could not be downloaded"))
|
||||
if reason == "offline"
|
||||
else f"the games index could not be downloaded ({failure})"))
|
||||
try:
|
||||
data = json.loads(raw.decode("utf-8"))
|
||||
except (UnicodeDecodeError, json.JSONDecodeError) as exc:
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/ins
|
||||
# curl or wget stop on a cut transfer before the hash is read: the site's
|
||||
# build rewrites this line there (scripts/sitebootstrap.py).
|
||||
MISMATCH_ADVICE="The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that."
|
||||
DEFAULT_INSTALL_SHA256="627e9c3bb72daacae022a93f5ca2ba010cd8fb025ef92d69f020734575ee9bad"
|
||||
DEFAULT_INSTALL_SHA256="7cbbbe3baefc4a03f5e8a85ee915df4ae23217d21aa61a2dcfccb4cbc846f546"
|
||||
MAX_INSTALLER_BYTES=2097152
|
||||
|
||||
cleanup() {
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
{
|
||||
"dest": "roms/ports/retrobios/install.py",
|
||||
"repo_path": "install.py",
|
||||
"size": 1080043,
|
||||
"sha256": "627e9c3bb72daacae022a93f5ca2ba010cd8fb025ef92d69f020734575ee9bad",
|
||||
"size": 1080006,
|
||||
"sha256": "7cbbbe3baefc4a03f5e8a85ee915df4ae23217d21aa61a2dcfccb4cbc846f546",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
@@ -71,8 +71,8 @@
|
||||
"muos": {
|
||||
"archive": {
|
||||
"dest": "ARCHIVE/RetroBIOS.muxapp",
|
||||
"size": 1133220,
|
||||
"sha256": "818f6453e8c441729b395a765f47735d5c3710a03db288ab5609b4485710d2cd"
|
||||
"size": 1133183,
|
||||
"sha256": "cc752f0ea8becaba5f3d96c6c77ca9c39b8b870fd9d2019985e1fd78ed912592"
|
||||
},
|
||||
"members": [
|
||||
{
|
||||
@@ -92,8 +92,8 @@
|
||||
{
|
||||
"name": "RetroBIOS/install.py",
|
||||
"repo_path": "install.py",
|
||||
"size": 1080043,
|
||||
"sha256": "627e9c3bb72daacae022a93f5ca2ba010cd8fb025ef92d69f020734575ee9bad",
|
||||
"size": 1080006,
|
||||
"sha256": "7cbbbe3baefc4a03f5e8a85ee915df4ae23217d21aa61a2dcfccb4cbc846f546",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
@@ -166,8 +166,8 @@
|
||||
{
|
||||
"dest": ".config/modules/retrobios/install.py",
|
||||
"repo_path": "install.py",
|
||||
"size": 1080043,
|
||||
"sha256": "627e9c3bb72daacae022a93f5ca2ba010cd8fb025ef92d69f020734575ee9bad",
|
||||
"size": 1080006,
|
||||
"sha256": "7cbbbe3baefc4a03f5e8a85ee915df4ae23217d21aa61a2dcfccb4cbc846f546",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
|
||||
@@ -22,6 +22,7 @@ import sys
|
||||
import tempfile
|
||||
import threading
|
||||
import unittest
|
||||
import urllib.error
|
||||
import zipfile
|
||||
import zlib
|
||||
from pathlib import Path
|
||||
@@ -777,6 +778,18 @@ class Unavailable(GamesTestCase):
|
||||
install.plan_games("retroarch", self.card.bios, manifest(), os_type="linux")
|
||||
self.assertEqual(caught.exception.reason, "offline")
|
||||
|
||||
def test_a_failed_download_says_why(self):
|
||||
"""The cause was printed only under RETROBIOS_DEBUG: a proxy's 403
|
||||
or a TLS refusal read as a bare "could not be downloaded"."""
|
||||
shutil.rmtree(self.card.lists / "games")
|
||||
refusal = urllib.error.HTTPError(
|
||||
"https://example.invalid/index.json", 403, "Forbidden", {}, None)
|
||||
with mock.patch.object(install, "_fetch_json", side_effect=refusal), \
|
||||
self.assertRaises(install.GamesUnavailable) as caught:
|
||||
install.GamesData().load_index(network=True, attempts=1)
|
||||
self.assertEqual(caught.exception.reason, "network")
|
||||
self.assertIn("403", caught.exception.words)
|
||||
|
||||
def test_a_document_that_is_not_the_one_listed_is_refused(self):
|
||||
(self.card.lists / "games" / "setups" / "retroarch.json").write_text("{}")
|
||||
with self.assertRaises(install.GamesUnavailable) as caught:
|
||||
|
||||
Reference in new issue
Block a user