From 6b2f22d562d390a099e3eacd197398dcc9f07c4e Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 6 Mar 2021 23:16:54 +0000 Subject: [PATCH] Check that media file is written --- content.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/content.py b/content.py index c1b2ff418..a0bbab004 100644 --- a/content.py +++ b/content.py @@ -973,9 +973,15 @@ def saveMediaInFormPOST(mediaBytes, debug: bool, os.remove(possibleOtherFormat) fd = open(filename, 'wb') + if not fd: + return None, None fd.write(mediaBytes[startPos:]) fd.close() + if not os.path.isfile(filename): + print('WARN: Media file could not be written to file: ' + filename) + return None, None + return filename, attachmentMediaType