mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
added handling for other potential errors
This commit is contained in:
+18
-3
@@ -183,12 +183,27 @@ pub(crate) async fn get_content_as_filename_route(
|
|||||||
media_id: &body.media_id,
|
media_id: &body.media_id,
|
||||||
};
|
};
|
||||||
|
|
||||||
let Ok(FileMeta {
|
let FileMeta {
|
||||||
content,
|
content,
|
||||||
content_type,
|
content_type,
|
||||||
content_disposition,
|
content_disposition,
|
||||||
}) = fetch_file(&services, &mxc, user, body.timeout_ms, None).await else {
|
} = match fetch_file(&services, &mxc, user, body.timeout_ms, None).await {
|
||||||
return Err!(Request(NotFound("Media not found.")));
|
Ok(meta) => meta,
|
||||||
|
Err(e) => {
|
||||||
|
match e {
|
||||||
|
conduwuit::Error::Io(e) => {
|
||||||
|
match e.kind() {
|
||||||
|
std::io::ErrorKind::PermissionDenied =>
|
||||||
|
// to not leak that a file exists
|
||||||
|
return Err!(Request(NotFound("Media not found."))),
|
||||||
|
std::io::ErrorKind::NotFound =>
|
||||||
|
return Err!(Request(NotFound("Media not found."))),
|
||||||
|
_ => return Err!(Request(Unknown("Unknown error when fetching file."))),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_ => return Err!(Request(Unknown("Unknown error when fetching file."))),
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(get_content_as_filename::v1::Response {
|
Ok(get_content_as_filename::v1::Response {
|
||||||
|
|||||||
Reference in New Issue
Block a user