From d1a360b4e3207a1e94c95a3f78e7663edb867b4a Mon Sep 17 00:00:00 2001 From: LA_DI_DA <11174151+0O0o0oOoO00@users.noreply.github.com> Date: Thu, 20 Mar 2025 12:31:43 +0800 Subject: [PATCH] add: remote file existence check --- module/luahook/crack.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/module/luahook/crack.py b/module/luahook/crack.py index 4a0fb269e..d985d1170 100644 --- a/module/luahook/crack.py +++ b/module/luahook/crack.py @@ -348,6 +348,13 @@ class CrackResource: logger.info(f"GameLibDir: {game_lib_dir}, do inject") self.device.adb_shell(f"cd {self.upload_dir} && ./patchelf --local-patch --game-lib-dir {game_lib_dir}") + def __is_remote_file_exist(self) -> bool: + def is_exist(path): + return self.device.adb_shell(f"if [ -d {path} ]; then echo 'exist'; else echo 'not exist'; fi") == "exist" + + return is_exist(self.upload_dir) and is_exist(f"{self.upload_dir}/libcracker.so") and is_exist(f"{self.upload_dir}/patchelf") + + def ensure(self): if not deep_get(self.config.data, "Hook.HookGeneral.Enable", False): return @@ -355,6 +362,6 @@ class CrackResource: self.__ensure_crack_resource() if not self.first_init: self.__check_update() - if self.has_new_version: + if self.has_new_version or not self.__is_remote_file_exist(): self.__push_resource() self.__do_inject()