diff --git a/changelog.d/1572.bugfix b/changelog.d/1572.bugfix new file mode 100644 index 000000000..1e03faf9e --- /dev/null +++ b/changelog.d/1572.bugfix @@ -0,0 +1 @@ +Fixed internal server errors for fetching thumbnails. Contributed by @PerformativeJade diff --git a/src/api/client/media.rs b/src/api/client/media.rs index 4d751b1d3..c3ea1ec93 100644 --- a/src/api/client/media.rs +++ b/src/api/client/media.rs @@ -114,7 +114,19 @@ pub(crate) async fn get_content_thumbnail_route( content, content_type, content_disposition, - } = fetch_thumbnail(&services, &mxc, user, body.timeout_ms, &dim).await?; + } = match fetch_thumbnail(&services, &mxc, user, body.timeout_ms, &dim).await { + | Ok(meta) => meta, + | Err(conduwuit::Error::Io(e)) => match e.kind() { + | std::io::ErrorKind::NotFound => + return Err!(Request(NotFound("Thumbnail not found."))), + | std::io::ErrorKind::PermissionDenied => { + error!("Permission denied when trying to read file: {e:?}"); + return Err!(Request(Unknown("Unknown error when fetching thumbnail."))); + }, + | _ => return Err!(Request(Unknown("Unknown error when fetching thumbnail."))), + }, + | Err(_) => return Err!(Request(Unknown("Unknown error when fetching thumbnail."))), + }; Ok(get_content_thumbnail::v1::Response { file: content.expect("entire file contents"),