From 32910c5cf590e1be372f51f672c3c62f29cfa521 Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 17 Mar 2023 12:50:19 +0200 Subject: [PATCH] remove new files if they exist too --- files/helpers/media.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/files/helpers/media.py b/files/helpers/media.py index 884e5a529..848c8ab2d 100644 --- a/files/helpers/media.py +++ b/files/helpers/media.py @@ -114,6 +114,8 @@ def convert_to_mp4(old, new, vid, db): subprocess.run(["ffmpeg", "-y", "-loglevel", "warning", "-nostats", "-threads:v", "1", "-i", old, "-map_metadata", "-1", tmp], check=True, stderr=subprocess.STDOUT) except: os.remove(old) + if os.path.isfile(tmp): + os.remove(tmp) abort(400) os.replace(tmp, new) @@ -161,6 +163,8 @@ def process_video(file, v): subprocess.run(["ffmpeg", "-y", "-loglevel", "warning", "-nostats", "-i", old, "-map_metadata", "-1", "-c:v", "copy", "-c:a", "copy", new], check=True) except: os.remove(old) + if os.path.isfile(new): + os.remove(new) abort(400) os.remove(old)