mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 20:44:04 +00:00
tusd: Support None value for MAX_WEB_DATA_IMPORT_SIZE_MB.
Adds support for `None` and defines how different values will be used in `prod_settings_template.py`.
This commit is contained in:
@@ -442,6 +442,7 @@ class TusdPreCreateTest(ZulipTestCase):
|
||||
|
||||
request = self.request(key=confirmation_key)
|
||||
|
||||
assert settings.MAX_WEB_DATA_IMPORT_SIZE_MB is not None
|
||||
max_upload_size = settings.MAX_WEB_DATA_IMPORT_SIZE_MB * 1024 * 1024
|
||||
request.event.upload.size = max_upload_size + 1
|
||||
result = self.client_post(
|
||||
|
||||
@@ -257,16 +257,18 @@ def authenticate_user(request: HttpRequest) -> UserProfile | AnonymousUser:
|
||||
def handle_preregistration_pre_create_hook(
|
||||
request: HttpRequest, preregistration_realm: PreregistrationRealm, data: TusUpload
|
||||
) -> HttpResponse:
|
||||
max_upload_size = settings.MAX_WEB_DATA_IMPORT_SIZE_MB * 1024 * 1024 # 1G
|
||||
if data.size_is_deferred or data.size is None:
|
||||
return reject_upload("SizeIsDeferred is not supported", 411)
|
||||
if data.size > max_upload_size:
|
||||
return reject_upload(
|
||||
_(
|
||||
"Uploaded file exceeds the maximum file size for imports ({max_file_size} MiB)."
|
||||
).format(max_file_size=settings.MAX_WEB_DATA_IMPORT_SIZE_MB),
|
||||
413,
|
||||
)
|
||||
|
||||
if settings.MAX_WEB_DATA_IMPORT_SIZE_MB is not None:
|
||||
max_upload_size = settings.MAX_WEB_DATA_IMPORT_SIZE_MB * 1024 * 1024 # 1G
|
||||
if data.size > max_upload_size:
|
||||
return reject_upload(
|
||||
_(
|
||||
"Uploaded file exceeds the maximum file size for imports ({max_file_size} MiB)."
|
||||
).format(max_file_size=settings.MAX_WEB_DATA_IMPORT_SIZE_MB),
|
||||
413,
|
||||
)
|
||||
|
||||
filename = f"import/{preregistration_realm.id}/slack.zip"
|
||||
|
||||
|
||||
@@ -698,9 +698,12 @@ CUSTOM_AUTHENTICATION_WRAPPER_FUNCTION: Callable[..., Any] | None = None
|
||||
# notification.
|
||||
RESOLVE_TOPIC_UNDO_GRACE_PERIOD_SECONDS = 60
|
||||
|
||||
# For realm imports during registration, maximum size of file
|
||||
# that can be uploaded.
|
||||
MAX_WEB_DATA_IMPORT_SIZE_MB = 1024
|
||||
# Maximum allowed size of uploaded file for realm import, in megabytes.
|
||||
# 0 disables import; None means no limit.
|
||||
#
|
||||
# Note that this is a limit for the size of the uploaded export
|
||||
# itself, not any additional files that may be imported as well.
|
||||
MAX_WEB_DATA_IMPORT_SIZE_MB: int | None = 1024
|
||||
|
||||
# Minimum and maximum permitted number of days before full data
|
||||
# deletion when deactivating an organization. A nonzero minimum helps
|
||||
|
||||
Reference in New Issue
Block a user