From c2e53766c280d75306c530548fdf294fb3939f39 Mon Sep 17 00:00:00 2001 From: asonix Date: Sat, 23 Dec 2023 12:48:32 -0600 Subject: [PATCH] Don't -ping when extracting file details (workaround for imagemagick json bug) --- src/discover/magick.rs | 6 +++--- src/magick.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/discover/magick.rs b/src/discover/magick.rs index aac38ae..46a229e 100644 --- a/src/discover/magick.rs +++ b/src/discover/magick.rs @@ -189,7 +189,7 @@ where "magick", &[ "convert".as_ref(), - "-ping".as_ref(), + // "-ping".as_ref(), // re-enable -ping after imagemagick fix input_file.as_os_str(), "JSON:".as_ref(), ], @@ -197,7 +197,7 @@ where timeout, )? .read() - .into_vec() + .into_string() .await; input_file.cleanup().await.map_err(MagickError::Cleanup)?; @@ -213,7 +213,7 @@ where } let output: Vec = - serde_json::from_slice(&output).map_err(MagickError::Json)?; + serde_json::from_str(&output).map_err(|e| MagickError::Json(output, e))?; parse_discovery(output).map_err(MagickError::Discover) } diff --git a/src/magick.rs b/src/magick.rs index d109987..7c82969 100644 --- a/src/magick.rs +++ b/src/magick.rs @@ -17,8 +17,8 @@ pub(crate) enum MagickError { #[error("Error in imagemagick process")] Process(#[source] ProcessError), - #[error("Invalid output format")] - Json(#[source] serde_json::Error), + #[error("Invalid output format: {0}")] + Json(String, #[source] serde_json::Error), #[error("Error writing bytes")] Write(#[source] std::io::Error), @@ -62,7 +62,7 @@ impl MagickError { match self { Self::CommandFailed(_) => ErrorCode::COMMAND_FAILURE, Self::Process(e) => e.error_code(), - Self::Json(_) + Self::Json(_, _) | Self::Write(_) | Self::CreateFile(_) | Self::CreateDir(_)