mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-11-09 22:14:59 +00:00
Try to clean up properly even if command errors
This commit is contained in:
parent
89a4e3995f
commit
df8fc00ad5
4 changed files with 17 additions and 9 deletions
|
@ -211,7 +211,7 @@ where
|
|||
let tmp_one = (f)(tmp_one).await?;
|
||||
tmp_one.close().await.map_err(FfMpegError::CloseFile)?;
|
||||
|
||||
let output = Process::run(
|
||||
let res = Process::run(
|
||||
"ffprobe",
|
||||
&[
|
||||
"-v".as_ref(),
|
||||
|
@ -230,10 +230,12 @@ where
|
|||
)?
|
||||
.read()
|
||||
.into_vec()
|
||||
.await?;
|
||||
.await;
|
||||
|
||||
input_file.cleanup().await.map_err(FfMpegError::Cleanup)?;
|
||||
|
||||
let output = res?;
|
||||
|
||||
let output: FfMpegDiscovery = serde_json::from_slice(&output).map_err(FfMpegError::Json)?;
|
||||
|
||||
let (discovery, pix_fmt) = parse_discovery(output)?;
|
||||
|
|
|
@ -117,7 +117,7 @@ where
|
|||
|
||||
let envs = [(MAGICK_TEMPORARY_PATH, temporary_path.as_os_str())];
|
||||
|
||||
let output = Process::run(
|
||||
let res = Process::run(
|
||||
"magick",
|
||||
&[
|
||||
"convert".as_ref(),
|
||||
|
@ -130,7 +130,7 @@ where
|
|||
)?
|
||||
.read()
|
||||
.into_string()
|
||||
.await?;
|
||||
.await;
|
||||
|
||||
input_file.cleanup().await.map_err(MagickError::Cleanup)?;
|
||||
temporary_path
|
||||
|
@ -138,6 +138,8 @@ where
|
|||
.await
|
||||
.map_err(MagickError::Cleanup)?;
|
||||
|
||||
let output = res?;
|
||||
|
||||
if output.is_empty() {
|
||||
return Err(MagickError::Empty);
|
||||
}
|
||||
|
@ -183,7 +185,7 @@ where
|
|||
|
||||
let envs = [(MAGICK_TEMPORARY_PATH, temporary_path.as_os_str())];
|
||||
|
||||
let output = Process::run(
|
||||
let res = Process::run(
|
||||
"magick",
|
||||
&[
|
||||
"convert".as_ref(),
|
||||
|
@ -196,7 +198,7 @@ where
|
|||
)?
|
||||
.read()
|
||||
.into_vec()
|
||||
.await?;
|
||||
.await;
|
||||
|
||||
input_file.cleanup().await.map_err(MagickError::Cleanup)?;
|
||||
temporary_path
|
||||
|
@ -204,6 +206,8 @@ where
|
|||
.await
|
||||
.map_err(MagickError::Cleanup)?;
|
||||
|
||||
let output = res?;
|
||||
|
||||
if output.is_empty() {
|
||||
return Err(MagickError::Empty);
|
||||
}
|
||||
|
|
|
@ -102,8 +102,9 @@ pub(super) async fn thumbnail<S: Store>(
|
|||
timeout,
|
||||
)?;
|
||||
|
||||
process.wait().await?;
|
||||
let res = process.wait().await;
|
||||
input_file.cleanup().await.map_err(FfMpegError::Cleanup)?;
|
||||
res?;
|
||||
|
||||
let tmp_two = crate::file::File::open(&output_file)
|
||||
.await
|
||||
|
|
|
@ -34,7 +34,7 @@ pub(super) async fn transcode_bytes(
|
|||
|
||||
let output_file = tmp_dir.tmp_file(None);
|
||||
|
||||
transcode_files(
|
||||
let res = transcode_files(
|
||||
input_file.as_os_str(),
|
||||
input_format,
|
||||
output_file.as_os_str(),
|
||||
|
@ -42,9 +42,10 @@ pub(super) async fn transcode_bytes(
|
|||
crf,
|
||||
timeout,
|
||||
)
|
||||
.await?;
|
||||
.await;
|
||||
|
||||
input_file.cleanup().await.map_err(FfMpegError::Cleanup)?;
|
||||
res?;
|
||||
|
||||
let tmp_two = crate::file::File::open(&output_file)
|
||||
.await
|
||||
|
|
Loading…
Reference in a new issue