diff options
author | 2022-05-22 12:24:09 +0100 | |
---|---|---|
committer | 2022-05-22 12:24:09 +0100 | |
commit | 9eab2b342b23dc7e637ed206c9b1b475cff0eab5 (patch) | |
tree | d5bd9e6d4826972ce2c90a8a6bf984d167e27961 | |
parent | Fix tests (diff) |
Ensure error uses correct maximum size
-rw-r--r-- | bot/utils/services.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/bot/utils/services.py b/bot/utils/services.py index c10f0cd46..3a6833e72 100644 --- a/bot/utils/services.py +++ b/bot/utils/services.py @@ -31,10 +31,11 @@ async def send_to_paste_service(contents: str, *, extension: str = "", max_lengt """ extension = extension and f".{extension}" + max_size = min(max_length, MAX_PASTE_LENGTH) contents_size = len(contents.encode()) - if contents_size > min(max_length, MAX_PASTE_LENGTH): - log.info("Contents too large to send to paste service. ") - raise PasteTooLongError(f"Contents of size {contents_size} greater than maximum size {MAX_PASTE_LENGTH}") + if contents_size > max_size: + log.info("Contents too large to send to paste service.") + raise PasteTooLongError(f"Contents of size {contents_size} greater than maximum size {max_size}") log.debug(f"Sending contents of size {contents_size} bytes to paste service.") paste_url = URLs.paste_service.format(key="documents") |