fix: abort if ffmpeg process errors
This commit is contained in:
parent
c0049cbb8d
commit
0475c52529
1 changed files with 10 additions and 5 deletions
|
@ -3,7 +3,8 @@ use std::{
|
|||
process::Stdio,
|
||||
};
|
||||
|
||||
use color_eyre::eyre::{ContextCompat, Result};
|
||||
use color_eyre::eyre::{ContextCompat, Result, bail};
|
||||
use futures::channel::oneshot;
|
||||
use relm4::{
|
||||
Sender,
|
||||
tokio::{
|
||||
|
@ -136,11 +137,10 @@ pub async fn convert_video(
|
|||
let mut reader = BufReader::new(stdout).lines();
|
||||
|
||||
// make sure the process is actually started and awaited
|
||||
let (tx, rx) = oneshot::channel();
|
||||
tokio::spawn(async move {
|
||||
child
|
||||
.wait()
|
||||
.await
|
||||
.expect("ffmpeg process encountered an error");
|
||||
tx.send(child.wait().await)
|
||||
.expect("could not send exit status");
|
||||
});
|
||||
|
||||
while let Some(line) = reader.next_line().await? {
|
||||
|
@ -157,5 +157,10 @@ pub async fn convert_video(
|
|||
}
|
||||
}
|
||||
|
||||
let status = rx.await??;
|
||||
if !status.success() {
|
||||
bail!("ffmpeg process errored: {status}");
|
||||
}
|
||||
|
||||
Ok(out_path)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue