mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 22:05:59 +00:00
feat: downloads resume where they stopped, and fall back to another source (#623)
This commit is contained in:
1 parent
59a5afa21d
commit
89a0e4d25f
53 files changed
+784
-221
No files matched your search
@@ -28,8 +28,21 @@ class SteamInstallTest(unittest.TestCase):
|
||||
curl = self.bin / 'curl'
|
||||
curl.write_text('''#!/bin/bash
|
||||
set -eu
|
||||
printf '%s\\n' "$2" >> "$TEST_REQUESTS"
|
||||
cp "$TEST_CDN/${2##*/}" "$4"
|
||||
url=""
|
||||
out=""
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
-o) out=$2; shift 2 ;;
|
||||
--connect-timeout|--max-time|--speed-limit|--speed-time|--retry|--retry-delay) shift 2 ;;
|
||||
-*) shift ;;
|
||||
*) url=$1; shift ;;
|
||||
esac
|
||||
done
|
||||
printf '%s\\n' "$url" >> "$TEST_REQUESTS"
|
||||
if [ -n "${TEST_FAIL_HOST:-}" ]; then
|
||||
case $url in *"$TEST_FAIL_HOST"*) exit 22 ;; esac
|
||||
fi
|
||||
cp "$TEST_CDN/${url##*/}" "$out"
|
||||
''')
|
||||
curl.chmod(0o755)
|
||||
if shutil.which('sha256sum') is None:
|
||||
@@ -55,11 +68,12 @@ cp "$TEST_CDN/${2##*/}" "$4"
|
||||
f'\t\t"file" "{archive.name}"\n\t\t"sha2" "{digest}"\n'
|
||||
'\t}\n}\n')
|
||||
|
||||
def install(self):
|
||||
return subprocess.run(['bash', str(SCRIPT)], env=self.env, text=True, capture_output=True)
|
||||
def install(self, fail_host=None):
|
||||
env = self.env if fail_host is None else dict(self.env, TEST_FAIL_HOST=fail_host)
|
||||
return subprocess.run(['bash', str(SCRIPT)], env=env, text=True, capture_output=True)
|
||||
|
||||
def assert_installed(self, channel='steamdeck_publicbeta'):
|
||||
result = self.install()
|
||||
def assert_installed(self, channel='steamdeck_publicbeta', fail_host=None, expected=None):
|
||||
result = self.install(fail_host)
|
||||
self.assertEqual(0, result.returncode, result.stderr)
|
||||
self.assertEqual(channel + '\n', (self.steam / 'package/beta').read_text())
|
||||
self.assertEqual('123456\n', (self.steam / 'package/droiddeck-installed').read_text())
|
||||
@@ -67,14 +81,24 @@ cp "$TEST_CDN/${2##*/}" "$4"
|
||||
self.assertTrue(os.access(client, os.X_OK))
|
||||
self.assertEqual(channel, client.read_text())
|
||||
self.assertEqual((self.steam / 'linuxarm64').resolve(), (self.home / '.steam/sdkarm64').resolve())
|
||||
self.assertEqual([
|
||||
'https://client-update.fastly.steamstatic.com/steam_client_' + channel + '_linuxarm64',
|
||||
'https://client-update.fastly.steamstatic.com/' + channel + '.zip',
|
||||
], self.requests.read_text().splitlines())
|
||||
if expected is None:
|
||||
expected = [
|
||||
'https://client-update.steamstatic.com/steam_client_' + channel + '_linuxarm64',
|
||||
'https://client-update.steamstatic.com/' + channel + '.zip',
|
||||
]
|
||||
self.assertEqual(expected, self.requests.read_text().splitlines())
|
||||
|
||||
def test_downloads_the_deck_beta_client(self):
|
||||
self.assert_installed()
|
||||
|
||||
def test_a_cdn_that_does_not_answer_hands_over_to_the_next_one(self):
|
||||
akamai = 'https://client-update.akamai.steamstatic.com'
|
||||
self.assert_installed(fail_host='client-update.steamstatic.com', expected=[
|
||||
'https://client-update.steamstatic.com/steam_client_steamdeck_publicbeta_linuxarm64',
|
||||
akamai + '/steam_client_steamdeck_publicbeta_linuxarm64',
|
||||
akamai + '/steamdeck_publicbeta.zip',
|
||||
])
|
||||
|
||||
def test_an_install_from_another_branch_is_left_for_steam_to_move(self):
|
||||
self.assert_installed()
|
||||
requests = self.requests.read_text()
|
||||
|
||||
Reference in new issue
Block a user