From 39b48c8b3a595bdc62c237f46d387262b77bfe3b Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Mon, 14 Nov 2022 06:53:50 +1100 Subject: [PATCH] Don't attempt to upload a video with a >2MB thumbnail --- cutter/cutter/main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cutter/cutter/main.py b/cutter/cutter/main.py index 73c493a..77159aa 100644 --- a/cutter/cutter/main.py +++ b/cutter/cutter/main.py @@ -465,6 +465,10 @@ class Cutter(object): # Assumed error is not retryable raise UploadError("Error while generating thumbnail: {}".format(ex), retryable=False) + if len(thumbnail) > 2 * 2**20: + self.logger.warning("Aborting upload as thumbnail is too big ({}MB, max 2MB)".format(len(thumbnail) / 2.**20)) + raise UploadError("Thumbnail is too big ({}MB, max 2MB)".format(len(thumbnail) / 2.**20), retryable=False) + # UploadErrors in the except block below should be caught # the same as UploadErrors in the main try block, so we wrap # a second try around the whole thing.