From 6187827e1bf4a687992be61e9b3cfdbe605ca3fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=80=E1=B4=8D=E1=B4=9B=E1=B4=8F=E1=B4=80=E1=B4=87?= =?UTF-8?q?=CA=80?= Date: Sun, 28 Jul 2024 15:34:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A1=AE=E4=BF=9D=E6=97=A0=E8=AE=BA?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E4=B8=8B=E8=BD=BD=E7=BB=93=E6=9E=9C=E5=A6=82?= =?UTF-8?q?=E4=BD=95=EF=BC=8C=E9=83=BD=E5=9C=A8=E6=9C=80=E7=BB=88=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E4=B8=B4=E6=97=B6=E6=96=87=E4=BB=B6=20(#159)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/bili_sync/src/downloader.rs | 2 -- crates/bili_sync/src/workflow.rs | 11 ++++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/bili_sync/src/downloader.rs b/crates/bili_sync/src/downloader.rs index 7a93168..365edf3 100644 --- a/crates/bili_sync/src/downloader.rs +++ b/crates/bili_sync/src/downloader.rs @@ -51,8 +51,6 @@ impl Downloader { _ => Err(anyhow!("ffmpeg error")), }; } - let _ = fs::remove_file(video_path).await; - let _ = fs::remove_file(audio_path).await; Ok(()) } } diff --git a/crates/bili_sync/src/workflow.rs b/crates/bili_sync/src/workflow.rs index dc446fd..6a7b7a1 100644 --- a/crates/bili_sync/src/workflow.rs +++ b/crates/bili_sync/src/workflow.rs @@ -485,9 +485,14 @@ pub async fn fetch_page_video( page_path.with_extension("tmp_video"), page_path.with_extension("tmp_audio"), ); - downloader.fetch(video_stream.url(), &tmp_video_path).await?; - downloader.fetch(audio_stream.url(), &tmp_audio_path).await?; - downloader.merge(&tmp_video_path, &tmp_audio_path, &page_path).await?; + let res = { + downloader.fetch(video_stream.url(), &tmp_video_path).await?; + downloader.fetch(audio_stream.url(), &tmp_audio_path).await?; + downloader.merge(&tmp_video_path, &tmp_audio_path, &page_path).await + }; + let _ = fs::remove_file(tmp_video_path).await; + let _ = fs::remove_file(tmp_audio_path).await; + res?; } } Ok(())