From 2fdb9f8b7ea198ea7405214d11053f840957cb92 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sat, 8 Jul 2023 21:17:55 +0000 Subject: [PATCH] fix: do not ignore errors in `try_calc_and_set_dimensions` --- src/message.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/message.rs b/src/message.rs index 8fc785c98..03ccd70c2 100644 --- a/src/message.rs +++ b/src/message.rs @@ -583,14 +583,22 @@ impl Message { if (self.viewtype == Viewtype::Image || self.viewtype == Viewtype::Gif) && !self.param.exists(Param::Width) { - self.param.set_int(Param::Width, 0); - self.param.set_int(Param::Height, 0); + let buf = read_file(context, &path_and_filename).await?; - if let Ok(buf) = read_file(context, path_and_filename).await { - if let Ok((width, height)) = get_filemeta(&buf) { + match get_filemeta(&buf) { + Ok((width, height)) => { self.param.set_int(Param::Width, width as i32); self.param.set_int(Param::Height, height as i32); } + Err(err) => { + self.param.set_int(Param::Width, 0); + self.param.set_int(Param::Height, 0); + warn!( + context, + "Failed to get width and height for {}: {err:#}.", + path_and_filename.display() + ); + } } if !self.id.is_unset() {