fix: Thumbnail fetching error handling

This commit is contained in:
PerformativeJade
2026-03-24 19:21:18 +00:00
committed by PerformativeJade
parent 2ffafc17d2
commit ed81dfc6cd
2 changed files with 14 additions and 1 deletions
+1
View File
@@ -0,0 +1 @@
Fixed internal server errors for fetching thumbnails. Contributed by @PerformativeJade
+13 -1
View File
@@ -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"),