Skip to content

Commit

Permalink
fix: one of audio and video finishing kills the job
Browse files Browse the repository at this point in the history
  • Loading branch information
kingwingfly committed Jun 6, 2024
1 parent c2ff380 commit 9bc408e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
2 changes: 0 additions & 2 deletions fav_core/src/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ where
_ => {}
}
}

} => {}
_ = tokio::signal::ctrl_c() => {
token.cancel();
Expand Down Expand Up @@ -304,7 +303,6 @@ where
_ => {}
}
}

} => {}
_ = tokio::signal::ctrl_c() => {
token.cancel();
Expand Down
18 changes: 3 additions & 15 deletions fav_utils/src/bili/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 9bc408e

Please sign in to comment.