mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Merge branch 'tweak/better-failure-feeback' into 'dev'
Add max stream size to config.json See merge request crafty-controller/crafty-commander!234
This commit is contained in:
commit
8d79d0777f
@ -8,6 +8,7 @@ from app.classes.shared.console import console
|
||||
from app.classes.shared.main_controller import Controller
|
||||
from app.classes.web.websocket_helper import websocket_helper
|
||||
from app.classes.web.base_handler import BaseHandler
|
||||
from app.classes.shared.translation import translation
|
||||
|
||||
try:
|
||||
import tornado.web
|
||||
@ -19,9 +20,6 @@ except ModuleNotFoundError as ex:
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Class & Function Defination
|
||||
MAX_STREAMED_SIZE = 1024 * 1024 * 1024
|
||||
|
||||
|
||||
@tornado.web.stream_request_body
|
||||
class UploadHandler(BaseHandler):
|
||||
@ -35,14 +33,36 @@ class UploadHandler(BaseHandler):
|
||||
self.translator = translator
|
||||
|
||||
def prepare(self):
|
||||
self.do_upload = True
|
||||
# pylint: disable=unused-variable
|
||||
api_key, token_data, exec_user = self.current_user
|
||||
# Class & Function Defination
|
||||
api_key, _token_data, exec_user = self.current_user
|
||||
server_id = self.get_argument("server_id", None)
|
||||
superuser = exec_user["superuser"]
|
||||
if api_key is not None:
|
||||
superuser = superuser and api_key.superuser
|
||||
user_id = exec_user["user_id"]
|
||||
stream_size_value = helper.get_setting("stream_size_GB")
|
||||
|
||||
MAX_STREAMED_SIZE = (1024 * 1024 * 1024) * stream_size_value
|
||||
|
||||
self.content_len = int(self.request.headers.get("Content-Length"))
|
||||
if self.content_len > MAX_STREAMED_SIZE:
|
||||
logger.error(
|
||||
f"User with ID {user_id} attempted to upload a file that"
|
||||
f" exceeded the max body size."
|
||||
)
|
||||
websocket_helper.broadcast_user(
|
||||
user_id,
|
||||
"send_start_error",
|
||||
{
|
||||
"error": translation.translate(
|
||||
"error",
|
||||
"fileTooLarge",
|
||||
self.controller.users.get_user_lang_by_id(user_id),
|
||||
),
|
||||
},
|
||||
)
|
||||
return
|
||||
self.do_upload = True
|
||||
|
||||
if superuser:
|
||||
exec_user_server_permissions = (
|
||||
|
@ -15,6 +15,7 @@
|
||||
"max_log_lines": 700,
|
||||
"max_audit_entries": 300,
|
||||
"disabled_language_files": ["lol_EN.json", ""],
|
||||
"stream_size_GB": 1,
|
||||
"keywords": ["help", "chunk"],
|
||||
"allow_nsfw_profile_pictures": false
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -176,7 +176,8 @@
|
||||
"not-downloaded": "We can't seem to find your executable file. Has it finished downloading? Are the permissions set to executable?",
|
||||
"portReminder": "We have detected this is the first time {} has been run. Make sure to forward port {} through your router/firewall to make this remotely accessible from the internet.",
|
||||
"start-error": "Server {} failed to start with error code: {}",
|
||||
"terribleFailure": "What a Terrible Failure!"
|
||||
"terribleFailure": "What a Terrible Failure!",
|
||||
"fileTooLarge": "Upload failed. File upload too large. Contact system administrator for assistance."
|
||||
},
|
||||
"footer": {
|
||||
"allRightsReserved": "All rights reserved",
|
||||
|
Loading…
Reference in New Issue
Block a user