From a0d40c94b54657d500ac834670a3932177963992 Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 4 Aug 2023 01:22:37 +0300 Subject: [PATCH] make a piece of code a little prettier --- files/helpers/media.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/files/helpers/media.py b/files/helpers/media.py index 92e2cd793..32fdb1a7e 100644 --- a/files/helpers/media.py +++ b/files/helpers/media.py @@ -133,12 +133,11 @@ def process_video(file, v): old = f'/videos/{time.time()}'.replace('.','') file.save(old) - size = os.stat(old).st_size - if (SITE_NAME != 'WPD' and - (size > MAX_VIDEO_SIZE_MB_PATRON * 1024 * 1024 - or not v.patron and size > MAX_VIDEO_SIZE_MB * 1024 * 1024)): - os.remove(old) - abort(413, f"Max video size is {MAX_VIDEO_SIZE_MB} MB ({MAX_VIDEO_SIZE_MB_PATRON} MB for {patron}s)") + if SITE_NAME != 'WPD': + size = os.stat(old).st_size + if size > MAX_VIDEO_SIZE_MB_PATRON * 1024 * 1024 or (not v.patron and size > MAX_VIDEO_SIZE_MB * 1024 * 1024): + os.remove(old) + abort(413, f"Max video size is {MAX_VIDEO_SIZE_MB} MB ({MAX_VIDEO_SIZE_MB_PATRON} MB for {patron}s)") name_original = secure_filename(file.filename) extension = name_original.split('.')[-1].lower()