From 11bf44b35e40a226426f565999e2642d12289608 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 1 Mar 2022 13:27:41 -0500 Subject: [PATCH] Add user feedback for wrong unzip path --- app/classes/web/ajax_handler.py | 14 +++++++++++++- app/translations/en_EN.json | 3 ++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/classes/web/ajax_handler.py b/app/classes/web/ajax_handler.py index 6e8f4a85..df3ecdbd 100644 --- a/app/classes/web/ajax_handler.py +++ b/app/classes/web/ajax_handler.py @@ -5,9 +5,12 @@ import logging import tornado.web import tornado.escape import bleach +import time from app.classes.shared.console import console from app.classes.shared.helpers import helper +from app.classes.web.websocket_helper import websocket_helper +from app.classes.shared.translation import translation from app.classes.shared.server import ServerOutBuf from app.classes.web.base_handler import BaseHandler @@ -331,7 +334,16 @@ class AjaxHandler(BaseHandler): elif page == "unzip_server": path = self.get_argument('path', None) - helper.unzipServer(path, exec_user['user_id']) + if helper.check_file_exists(path): + helper.unzipServer(path, exec_user['user_id']) + else: + user_id = exec_user['user_id'] + if user_id: + time.sleep(5) + user_lang = self.controller.users.get_user_lang_by_id(user_id) + websocket_helper.broadcast_user(user_id, 'send_start_error',{ + 'error': translation.translate('error', 'no-file', user_lang) + }) return elif page == "backup_select": diff --git a/app/translations/en_EN.json b/app/translations/en_EN.json index ba6dba3c..aeb9e69e 100644 --- a/app/translations/en_EN.json +++ b/app/translations/en_EN.json @@ -18,7 +18,8 @@ "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.", - "not-downloaded": "We can't seem to find your executable file. Has it finished downloading? Are the permissions set to executable?" + "not-downloaded": "We can't seem to find your executable file. Has it finished downloading? Are the permissions set to executable?", + "no-file": "We can't seem to locate the requested file. Double check the path. Does Crafty have proper permissions?" }, "404": { "contact": "Contact Crafty Control Support via Discord",