diff --git a/docs/installer.md b/docs/installer.md index 3cbe0ce2..942cb282 100644 --- a/docs/installer.md +++ b/docs/installer.md @@ -77,7 +77,7 @@ loads the saves 1.4.3 wrote. `nvngx_dlss.dll` from NVIDIA's own DLSS SDK repository (github.com/NVIDIA/DLSS, a pinned tag, NVIDIA RTX SDK license) into the install folder and check its size and SHA-256 (`steps.py`, `Dlss`). The release does not ship the library; NGX loads it from the folder of totk.exe for `dlaa` and the DLSS modes. A DLSS library already in the - folder (a newer one the player put there) is kept. Without an RTX GPU the step warns and does nothing; a failed + folder (a newer one the player put there) is kept. Without an RTX GPU the step only logs and does nothing; a failed download warns, the game runs without DLSS, and the next run of the setup tries again. 8. **Clean up** the temp folder, except the generated C and the objects (about 1.3 GB), and write `build-cache/rebuild.txt` in the install folder. diff --git a/installer/gui.py b/installer/gui.py index 341d63ac..a0709cc6 100644 --- a/installer/gui.py +++ b/installer/gui.py @@ -312,7 +312,7 @@ class App: def pick_file(self, name, pick_id): # One filter for every game file: the setup tells an NSZ or XCZ from a plain file by its content (Check.unpack) - types = [(self.cat('ui.type_game'), '*.nsp *.xci *.nsz *.xcz')] + types = [(self.cat('ui.type_game'), '*.nsp *.xci *.nsz *.xcz'), (self.cat('ui.type_all'), '*.*')] if name == 'keys': types = [(self.cat('ui.type_keys'), '*.keys'), (self.cat('ui.type_all'), '*.*')] path = filedialog.askopenfilename(title=self.cat(pick_id), filetypes=types) diff --git a/installer/steps.py b/installer/steps.py index ecdd0dfa..2a7c089e 100644 --- a/installer/steps.py +++ b/installer/steps.py @@ -20,6 +20,7 @@ its rebuild mode on the install folder (installer/gui.py --rebuild), one argumen when an enabled mod has code cheats the build lacks (runtime/cheats.c). """ import hashlib +import http.client import json import os import re @@ -1156,7 +1157,8 @@ class Dlss(Step): if os.name != 'nt': return {'skipped': 'not_windows'} if not nvidia_rtx(getattr(ctx, 'host', None)): - ctx.reporter.warning('warn.dlss_no_rtx') + # The box is ticked by default, so most players without an RTX GPU never chose it: a log line, no warning + ctx.reporter.log('dlss: no NVIDIA RTX GPU among the Vulkan devices, nothing downloaded') return {'skipped': 'no_rtx'} rep, target = ctx.reporter, ctx.dest / DLSS_DLL if target.is_file(): @@ -1180,7 +1182,9 @@ class Dlss(Step): raise OSError(f'{done} bytes, SHA-256 {h.hexdigest()[:16]}, not the expected file') replace_file(part, target) remove(part) - except OSError as e: # urllib's errors, timeouts and a bad file + # urllib's errors, timeouts and a bad file; a connection cut mid-file raises http.client.IncompleteRead, + # which is not an OSError + except (OSError, http.client.HTTPException) as e: remove(part) rep.warning('warn.dlss_download_failed', url=DLSS_URL, detail=str(e)[:300]) return {'failed': True} diff --git a/installer/text/en.json b/installer/text/en.json index a47e9c4b..418ce82c 100644 --- a/installer/text/en.json +++ b/installer/text/en.json @@ -106,7 +106,6 @@ "warn.xbox_prompts_failed": "The Xbox button prompts could not be prepared (exit code {code}); the game keeps the Switch prompts. Details: {log}", "warn.shaders_skipped": "The graphics driver crashed while building some shaders, so {count} were left out of the preparation. The game builds them when it first needs them, and the driver may crash there too; a driver update may fix it. Details: {log}", "warn.kernel_old": "Linux {version} lacks the write tracking the game relies on (6.7 or later); the game may run very slowly. Updating the system fixes this.", - "warn.dlss_no_rtx": "No NVIDIA RTX graphics card was found, so NVIDIA DLSS was not downloaded; the game runs without it.", "warn.dlss_kept": "A DLSS library is already in the install folder ({path}); the setup keeps it.", "warn.dlss_download_failed": "NVIDIA DLSS could not be downloaded from {url}: {detail}. The game runs without it; the next setup run tries again.", diff --git a/installer/text/pt-BR.json b/installer/text/pt-BR.json index bd44161e..8839ac2b 100644 --- a/installer/text/pt-BR.json +++ b/installer/text/pt-BR.json @@ -106,7 +106,6 @@ "warn.xbox_prompts_failed": "Não foi possível preparar os ícones de botão do Xbox (código de saída {code}); o jogo mantém os ícones do Switch. Detalhes: {log}", "warn.shaders_skipped": "O driver gráfico travou ao compilar alguns shaders, então {count} ficaram fora da preparação. O jogo os compila quando precisar deles pela primeira vez, e o driver pode travar ali também; uma atualização do driver pode resolver. Detalhes: {log}", "warn.kernel_old": "O Linux {version} não tem o rastreamento de escrita de que o jogo depende (6.7 ou mais novo); o jogo pode rodar muito devagar. Atualizar o sistema resolve.", - "warn.dlss_no_rtx": "Nenhuma placa de vídeo NVIDIA RTX foi encontrada, então o NVIDIA DLSS não foi baixado; o jogo funciona sem ele.", "warn.dlss_kept": "Já existe uma biblioteca DLSS na pasta de instalação ({path}); a instalação a mantém.", "warn.dlss_download_failed": "Não foi possível baixar o NVIDIA DLSS de {url}: {detail}. O jogo funciona sem ele; a próxima execução da instalação tenta de novo.", diff --git a/installer/text/ru.json b/installer/text/ru.json index eba22a6e..58d12e65 100644 --- a/installer/text/ru.json +++ b/installer/text/ru.json @@ -106,7 +106,6 @@ "warn.xbox_prompts_failed": "Не удалось подготовить подсказки кнопок Xbox (код выхода {code}); игра оставит подсказки Switch. Подробности: {log}", "warn.shaders_skipped": "Графический драйвер аварийно завершился при сборке части шейдеров, поэтому {count} из них пропущены при подготовке. Игра соберёт их, когда они впервые понадобятся, и драйвер может упасть и там; обновление драйвера может это исправить. Подробности: {log}", "warn.kernel_old": "В Linux {version} нет отслеживания записи, на которое опирается игра (нужна версия 6.7 или новее); игра может работать очень медленно. Обновление системы это исправит.", - "warn.dlss_no_rtx": "Видеокарта NVIDIA RTX не найдена, поэтому NVIDIA DLSS не загружен; игра работает и без него.", "warn.dlss_kept": "В папке установки уже есть библиотека DLSS ({path}); установка её оставляет.", "warn.dlss_download_failed": "Не удалось загрузить NVIDIA DLSS с {url}: {detail}. Игра работает и без него; при следующем запуске установка попробует снова.", diff --git a/installer/text/zh-Hans.json b/installer/text/zh-Hans.json index 6716f257..168c5f96 100644 --- a/installer/text/zh-Hans.json +++ b/installer/text/zh-Hans.json @@ -106,7 +106,6 @@ "warn.xbox_prompts_failed": "无法准备 Xbox 按键提示(退出代码 {code});游戏将继续使用 Switch 按键提示。详情:{log}", "warn.shaders_skipped": "显卡驱动在编译部分着色器时崩溃,因此有 {count} 个着色器未被预先准备。游戏会在首次需要时编译它们,驱动在那时也可能崩溃;更新驱动可能会解决。详情:{log}", "warn.kernel_old": "Linux {version} 缺少游戏依赖的写入跟踪功能(需要 6.7 或更新版本);游戏可能运行得很慢。更新系统即可解决。", - "warn.dlss_no_rtx": "未找到 NVIDIA RTX 显卡,因此未下载 NVIDIA DLSS;游戏无需它也能运行。", "warn.dlss_kept": "安装文件夹中已有 DLSS 库({path});安装程序将保留它。", "warn.dlss_download_failed": "无法从 {url} 下载 NVIDIA DLSS:{detail}。游戏无需它也能运行;下次运行安装程序时会重试。", diff --git a/tests/installer_test.py b/tests/installer_test.py index c2537c7f..0e1d67ff 100644 --- a/tests/installer_test.py +++ b/tests/installer_test.py @@ -3,6 +3,7 @@ with a newer release, totk.ini and the event stream. No game files, no tools; st Run: python tests/installer_test.py """ +import http.client import io import json import re @@ -11,6 +12,7 @@ import tempfile import unittest from pathlib import Path from types import SimpleNamespace +from unittest import mock ROOT = Path(__file__).resolve().parent.parent sys.path.insert(0, str(ROOT)) @@ -626,6 +628,17 @@ class DlssTest(unittest.TestCase): self.assertEqual(self.warnings(), ['warn.dlss_download_failed']) self.assertFalse(steps.Dlss().current(self.ctx, rec)) + def test_a_cut_connection_warns(self): + class Cut(io.BytesIO): # a response whose connection drops mid-file + def read(self, n=-1): + raise http.client.IncompleteRead(b'dl', 3998) + + with mock.patch.object(steps.urllib.request, 'urlopen', return_value=Cut()): + self.assertEqual(steps.Dlss().run(self.ctx), {'failed': True}) + self.assertFalse((self.dest / 'nvngx_dlss.dll').exists()) + self.assertFalse(list(self.ctx.temp.iterdir())) + self.assertEqual(self.warnings(), ['warn.dlss_download_failed']) + def test_keeps_the_players_library(self): (self.dest / 'nvngx_dlss.dll').write_bytes(b'newer') self.assertEqual(steps.Dlss().run(self.ctx), {'kept': True}) @@ -635,7 +648,7 @@ class DlssTest(unittest.TestCase): def test_skipped_without_an_rtx_gpu(self): self.ctx.host = {'devices': [{'name': 'AMD Radeon RX 7800 XT', 'api': [1, 3, 0], 'type': 2}]} self.assertEqual(steps.Dlss().run(self.ctx), {'skipped': 'no_rtx'}) - self.assertEqual(self.warnings(), ['warn.dlss_no_rtx']) + self.assertEqual(self.warnings(), []) if __name__ == '__main__':