From 49fc4056ad8489b0dfd6990e51288be77846a727 Mon Sep 17 00:00:00 2001 From: mykola2312 Date: Sat, 16 Mar 2024 05:52:39 +0200 Subject: [PATCH] always delete intermediate files --- src/dl.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/dl.rs b/src/dl.rs index 4b5b1c7..2556993 100644 --- a/src/dl.rs +++ b/src/dl.rs @@ -152,19 +152,19 @@ pub async fn download(url: &str) -> Result { vf.format_id, af.format_id ); - match FFMpeg::join_audio_video( + + let res = FFMpeg::join_audio_video( video_path.as_str(), audio_path.as_str(), abr, output_path.as_str(), ) - .await - { + .await; + delete_if_exists(&video_path); + delete_if_exists(&audio_path); + + match res { Ok(()) => Ok(output_path), - Err(e) => { - delete_if_exists(&video_path); - delete_if_exists(&audio_path); - return Err(DownloadError::Message(e.to_string())); - } + Err(e) => Err(DownloadError::Message(e.to_string())), } }