From 9bc408e971b4fa53daa7bd7246c294e5880df273 Mon Sep 17 00:00:00 2001 From: Louis <836250617@qq.com> Date: Fri, 7 Jun 2024 03:31:39 +0800 Subject: [PATCH] fix: one of audio and video finishing kills the job --- fav_core/src/ops.rs | 2 -- fav_utils/src/bili/local.rs | 18 +++--------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/fav_core/src/ops.rs b/fav_core/src/ops.rs index 06a7ede..be19e0f 100644 --- a/fav_core/src/ops.rs +++ b/fav_core/src/ops.rs @@ -190,7 +190,6 @@ where _ => {} } } - } => {} _ = tokio::signal::ctrl_c() => { token.cancel(); @@ -304,7 +303,6 @@ where _ => {} } } - } => {} _ = tokio::signal::ctrl_c() => { token.cancel(); diff --git a/fav_utils/src/bili/local.rs b/fav_utils/src/bili/local.rs index 3e56c47..3c7fc17 100644 --- a/fav_utils/src/bili/local.rs +++ b/fav_utils/src/bili/local.rs @@ -51,33 +51,21 @@ impl SaveLocal for Bili { let mut file_v = BufWriter::new(tempfile::NamedTempFile::new()?); let mut file_a = BufWriter::new(tempfile::NamedTempFile::new()?); - let mut finish_v = false; - let mut finish_a = false; tokio::select! { - res = async { + _ = async { while let Some(chunk) = resp_v.chunk().await? { pb.inc(chunk.len() as u64); file_v.write_all(&chunk)?; } - finish_v = true; - Ok(()) - }, if !finish_v => { - res - }, - res = async { while let Some(chunk) = resp_a.chunk().await? { pb.inc(chunk.len() as u64); file_a.write_all(&chunk)?; } - finish_a = true; - Ok(()) - }, if !finish_a => { - res - }, - _ = async {}, if finish_v && finish_a => { file_v.flush().unwrap(); file_a.flush().unwrap(); pb.finish(); + FavCoreResult::Ok(()) + } => { merge( title, &id,