Merge branch 'pretzel-file-check' into 'dev'

Add check to make sure server file is downloaded before attempting to start

See merge request crafty-controller/crafty-commander!169
This commit is contained in:
Andrew 2022-02-27 17:29:57 +00:00
commit 8fb52c40b6
2 changed files with 14 additions and 1 deletions

View File

@ -240,6 +240,18 @@ class Server:
logger.info(f"Starting server in {self.server_path} with command: {self.server_command}") 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": 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") logger.info(f"Bedrock and Unix detected for server {self.name}. Switching to appropriate execution string")
my_env = os.environ my_env = os.environ

View File

@ -17,7 +17,8 @@
"eulaTitle": "Agree To EULA", "eulaTitle": "Agree To EULA",
"eulaMsg": "You must agree to the EULA. A copy of the Mojang EULA is linked under this message.", "eulaMsg": "You must agree to the EULA. A copy of the Mojang EULA is linked under this message.",
"eulaAgree": "Do you agree?", "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": { "404": {
"contact": "Contact Crafty Control Support via Discord", "contact": "Contact Crafty Control Support via Discord",