From dcd875c40c72101bd8133d44b0e47469995c922d Mon Sep 17 00:00:00 2001 From: justcool393 Date: Tue, 11 Oct 2022 23:27:17 -0700 Subject: [PATCH] max image and video size are constants now * the error pages still need to be fixed --- files/helpers/const.py | 6 ++++++ files/helpers/media.py | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/files/helpers/const.py b/files/helpers/const.py index 106b7acec..4ac20673d 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -395,6 +395,12 @@ GIFT_NOTIF_ID = 5 SIGNUP_FOLLOW_ID = 0 NOTIFICATION_THREAD = 1 +MAX_IMAGE_SIZE_BANNER_RESIZED_MB = 1 +MAX_IMAGE_SIZE_MB = 8 +MAX_IMAGE_SIZE_MB_PATRON = 16 +MAX_VIDEO_SIZE_MB = 32 +MAX_VIDEO_SIZE_MB_PATRON = 64 + if SITE == 'rdrama.net': FEATURES['PRONOUNS'] = True FEATURES['HOUSES'] = True diff --git a/files/helpers/media.py b/files/helpers/media.py index 8be8d47e0..cabc4324d 100644 --- a/files/helpers/media.py +++ b/files/helpers/media.py @@ -43,7 +43,7 @@ def process_audio(file): file.save(name) size = os.stat(name).st_size - if size > 16 * 1024 * 1024 or not g.v.patron and size > 8 * 1024 * 1024: + if size > MAX_IMAGE_SIZE_MB_PATRON * 1024 * 1024 or not g.v.patron and size > MAX_IMAGE_SIZE_MB * 1024 * 1024: os.remove(name) abort(413) @@ -90,7 +90,7 @@ def process_video(file): file.save(old) size = os.stat(old).st_size - if SITE_NAME != 'WPD' and (size > 32 * 1024 * 1024 or not g.v.patron and size > 64 * 1024 * 1024): + if SITE_NAME != 'WPD' and (size > MAX_VIDEO_SIZE_MB * 1024 * 1024 or not g.v.patron and size > MAX_VIDEO_SIZE_MB_PATRON * 1024 * 1024): os.remove(old) abort(414) @@ -125,7 +125,7 @@ def process_video(file): def process_image(filename=None, resize=0, trim=False, uploader=None, patron=False, db=None): size = os.stat(filename).st_size - if size > 16 * 1024 * 1024 or not patron and size > 8 * 1024 * 1024: + if size > MAX_IMAGE_SIZE_MB_PATRON * 1024 * 1024 or not patron and size > MAX_IMAGE_SIZE_MB * 1024 * 1024: os.remove(filename) abort(413) @@ -154,7 +154,7 @@ def process_image(filename=None, resize=0, trim=False, uploader=None, patron=Fal if resize in (300,400,1200): - if os.stat(filename).st_size > 1 * 1024 * 1024: + if os.stat(filename).st_size > MAX_IMAGE_SIZE_BANNER_RESIZED_MB * 1024 * 1024: os.remove(filename) abort(413)