From 72dcdc0534415d6360cda6c60d944116a4cfced2 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sun, 1 Nov 2026 21:22:52 +0800 Subject: [PATCH] Report a busy totk_xlate.exe in the prepare step the way the compile step reports a busy game exe The prepare step copies the shader translator with replace_file, which writes .tmp and then os.replace. A preparation that was stopped from outside leaves the totk_xlate.exe that totk.exe started holding that file, and Windows refuses the replace with PermissionError [WinError 5]. The setup showed that as an unexpected error and said nothing about what to close (issue #174). Catch the PermissionError on both copies and name the file, as compile.exe_in_use already does for totk.exe. Co-authored-by: deepseek-v4.1-flash-1017 --- installer/steps.py | 12 ++++++++++-- installer/text/en.json | 1 + installer/text/pt-BR.json | 1 + installer/text/ru.json | 1 + installer/text/zh-Hans.json | 1 + 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/installer/steps.py b/installer/steps.py index 1ac63909..16adad82 100644 --- a/installer/steps.py +++ b/installer/steps.py @@ -838,10 +838,18 @@ class Prepare(Step): # Another translator: its cache keys differ, so the old translations would only take space. for name in ('shader-cache', 'shader-prepared.bin'): remove(dest / name) - replace_file(layout.xlate, xlate) + # totk.exe starts totk_xlate.exe as a child while it prepares shaders; a preparation that was stopped from + # outside leaves that child holding this file, and Windows then refuses to replace it (issue #174). + try: + replace_file(layout.xlate, xlate) + except PermissionError: + raise InstallError('prepare.xlate_in_use', path=str(xlate)) from None xlate_id = layout.xlate.with_suffix('.id') if xlate_id.is_file(): - replace_file(xlate_id, xlate.with_suffix('.id')) + try: + replace_file(xlate_id, xlate.with_suffix('.id')) + except PermissionError: + raise InstallError('prepare.xlate_in_use', path=str(xlate.with_suffix('.id'))) from None else: remove(xlate.with_suffix('.id')) diff --git a/installer/text/en.json b/installer/text/en.json index 6f06ab4e..a4bb4bc5 100644 --- a/installer/text/en.json +++ b/installer/text/en.json @@ -85,6 +85,7 @@ "lift.failed": "Translating the game code failed (exit code {code}). Details: {log}", "compile.failed": "Compiling {game_exe} failed (exit code {code}). Details: {log}", "compile.exe_in_use": "{path} is in use. Close the game and run the installer again.", + "prepare.xlate_in_use": "{path} is in use. Close the game, end any totk_xlate process left from an earlier run, then run the installer again.", "prepare.shader_list_missing": "The shader list is missing.", "prepare.romfs_patches_failed": "Writing the game data patches failed (exit code {code}). Details: {log}", "prepare.shaders_failed": "Preparing the shaders failed (exit code {code}). Details: {log}", diff --git a/installer/text/pt-BR.json b/installer/text/pt-BR.json index f56a5f85..9d06b270 100644 --- a/installer/text/pt-BR.json +++ b/installer/text/pt-BR.json @@ -85,6 +85,7 @@ "lift.failed": "Falha ao traduzir o código do jogo (código de saída {code}). Detalhes: {log}", "compile.failed": "Falha ao compilar o {game_exe} (código de saída {code}). Detalhes: {log}", "compile.exe_in_use": "{path} está em uso. Feche o jogo e execute o instalador de novo.", + "prepare.xlate_in_use": "{path} está em uso. Feche o jogo, encerre qualquer processo totk_xlate que tenha sobrado de uma execução anterior e execute o instalador de novo.", "prepare.shader_list_missing": "A lista de shaders está faltando.", "prepare.romfs_patches_failed": "Falha ao gravar os patches nos dados do jogo (código de saída {code}). Detalhes: {log}", "prepare.shaders_failed": "Falha ao preparar os shaders (código de saída {code}). Detalhes: {log}", diff --git a/installer/text/ru.json b/installer/text/ru.json index 72db03d2..8225cc8e 100644 --- a/installer/text/ru.json +++ b/installer/text/ru.json @@ -85,6 +85,7 @@ "lift.failed": "Не удалось перевести код игры (код выхода {code}). Подробности: {log}", "compile.failed": "Не удалось собрать {game_exe} (код выхода {code}). Подробности: {log}", "compile.exe_in_use": "Файл {path} занят. Закройте игру и запустите установку снова.", + "prepare.xlate_in_use": "Файл {path} занят. Закройте игру, завершите процесс totk_xlate, оставшийся от прошлого запуска, и запустите установку снова.", "prepare.shader_list_missing": "Нет списка шейдеров.", "prepare.romfs_patches_failed": "Не удалось записать патчи данных игры (код выхода {code}). Подробности: {log}", "prepare.shaders_failed": "Не удалось подготовить шейдеры (код выхода {code}). Подробности: {log}", diff --git a/installer/text/zh-Hans.json b/installer/text/zh-Hans.json index a0c317ed..ad2bcb42 100644 --- a/installer/text/zh-Hans.json +++ b/installer/text/zh-Hans.json @@ -85,6 +85,7 @@ "lift.failed": "游戏代码转换失败(退出代码 {code})。详情:{log}", "compile.failed": "编译 {game_exe} 失败(退出代码 {code})。详情:{log}", "compile.exe_in_use": "{path} 正在使用中。请关闭游戏后重新运行安装程序。", + "prepare.xlate_in_use": "{path} 正在被占用。请关闭游戏,结束上次残留的 totk_xlate 进程,再重新运行安装程序。", "prepare.shader_list_missing": "缺少着色器列表。", "prepare.romfs_patches_failed": "写入游戏数据补丁失败(退出代码 {code})。详情:{log}", "prepare.shaders_failed": "准备着色器失败(退出代码 {code})。详情:{log}",