From dfed1cbedc00f69475bb5e28f407cd9450008262 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 27 Feb 2022 12:22:52 -0500 Subject: [PATCH] Add check to make sure server file is downloaded before attempting to start --- app/classes/shared/server.py | 12 ++++++++++++ app/translations/en_EN.json | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/classes/shared/server.py b/app/classes/shared/server.py index 82e1c1da..0e84472d 100644 --- a/app/classes/shared/server.py +++ b/app/classes/shared/server.py @@ -240,6 +240,18 @@ class Server: logger.info(f"Starting server in {self.server_path} with command: {self.server_command}") + #checks to make sure file is openable (downloaded) and exists. + try: + f = open(os.path.join(self.server_path, servers_helper.get_server_data_by_id(self.server_id)['executable']), "r", encoding="utf-8") + f.close() + + except: + if user_id: + websocket_helper.broadcast_user(user_id, 'send_start_error',{ + 'error': translation.translate('error', 'not-downloaded', user_lang) + }) + return + if not helper.is_os_windows() and servers_helper.get_server_type_by_id(self.server_id) == "minecraft-bedrock": logger.info(f"Bedrock and Unix detected for server {self.name}. Switching to appropriate execution string") my_env = os.environ diff --git a/app/translations/en_EN.json b/app/translations/en_EN.json index 60bfd4c2..e7d5105d 100644 --- a/app/translations/en_EN.json +++ b/app/translations/en_EN.json @@ -17,7 +17,8 @@ "eulaTitle": "Agree To EULA", "eulaMsg": "You must agree to the EULA. A copy of the Mojang EULA is linked under this message.", "eulaAgree": "Do you agree?", - "noJava": "Server {} failed to start with error code: We have detected Java is not installed. Please install java then start the server." + "noJava": "Server {} failed to start with error code: We have detected Java is not installed. Please install java then start the server.", + "not-downloaded": "We can't seem to find your executable file. Has it finished downloading? Are the permissions set to executable?" }, "404": { "contact": "Contact Crafty Control Support via Discord",