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,
|
process::Stdio,
|
||||||
};
|
};
|
||||||
|
|
||||||
use color_eyre::eyre::{ContextCompat, Result};
|
use color_eyre::eyre::{ContextCompat, Result, bail};
|
||||||
|
use futures::channel::oneshot;
|
||||||
use relm4::{
|
use relm4::{
|
||||||
Sender,
|
Sender,
|
||||||
tokio::{
|
tokio::{
|
||||||
|
@ -136,11 +137,10 @@ pub async fn convert_video(
|
||||||
let mut reader = BufReader::new(stdout).lines();
|
let mut reader = BufReader::new(stdout).lines();
|
||||||
|
|
||||||
// make sure the process is actually started and awaited
|
// make sure the process is actually started and awaited
|
||||||
|
let (tx, rx) = oneshot::channel();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
child
|
tx.send(child.wait().await)
|
||||||
.wait()
|
.expect("could not send exit status");
|
||||||
.await
|
|
||||||
.expect("ffmpeg process encountered an error");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
while let Some(line) = reader.next_line().await? {
|
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)
|
Ok(out_path)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue