mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
report permission denied errors
This commit is contained in:
+15
-19
@@ -6,6 +6,7 @@ use conduwuit::{
|
|||||||
Err, Result, err,
|
Err, Result, err,
|
||||||
utils::{self, content_disposition::make_content_disposition, math::ruma_from_usize},
|
utils::{self, content_disposition::make_content_disposition, math::ruma_from_usize},
|
||||||
};
|
};
|
||||||
|
use conduwuit_core::error;
|
||||||
use conduwuit_service::{
|
use conduwuit_service::{
|
||||||
Services,
|
Services,
|
||||||
media::{CACHE_CONTROL_IMMUTABLE, CORP_CROSS_ORIGIN, Dim, FileMeta, MXC_LENGTH},
|
media::{CACHE_CONTROL_IMMUTABLE, CORP_CROSS_ORIGIN, Dim, FileMeta, MXC_LENGTH},
|
||||||
@@ -144,22 +145,19 @@ pub(crate) async fn get_content_route(
|
|||||||
server_name: &body.server_name,
|
server_name: &body.server_name,
|
||||||
media_id: &body.media_id,
|
media_id: &body.media_id,
|
||||||
};
|
};
|
||||||
|
|
||||||
let FileMeta {
|
let FileMeta {
|
||||||
content,
|
content,
|
||||||
content_type,
|
content_type,
|
||||||
content_disposition,
|
content_disposition,
|
||||||
} = match fetch_file(&services, &mxc, user, body.timeout_ms, None).await {
|
} = match fetch_file(&services, &mxc, user, body.timeout_ms, None).await {
|
||||||
| Ok(meta) => meta,
|
| Ok(meta) => meta,
|
||||||
| Err(conduwuit::Error::Io(e)) => {
|
| Err(conduwuit::Error::Io(e)) => match e.kind() {
|
||||||
if matches!(
|
| std::io::ErrorKind::NotFound => return Err!(Request(NotFound("Media not found."))),
|
||||||
e.kind(),
|
| std::io::ErrorKind::PermissionDenied => {
|
||||||
std::io::ErrorKind::PermissionDenied | std::io::ErrorKind::NotFound
|
error!("Permission denied when trying to read file: {e:?}");
|
||||||
) {
|
return Err!(Request(Unknown("Unknown error when fetching file.")));
|
||||||
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.")));
|
|
||||||
},
|
},
|
||||||
| Err(_) => return Err!(Request(Unknown("Unknown error when fetching file."))),
|
| Err(_) => return Err!(Request(Unknown("Unknown error when fetching file."))),
|
||||||
};
|
};
|
||||||
@@ -200,15 +198,13 @@ pub(crate) async fn get_content_as_filename_route(
|
|||||||
content_disposition,
|
content_disposition,
|
||||||
} = match fetch_file(&services, &mxc, user, body.timeout_ms, None).await {
|
} = match fetch_file(&services, &mxc, user, body.timeout_ms, None).await {
|
||||||
| Ok(meta) => meta,
|
| Ok(meta) => meta,
|
||||||
| Err(conduwuit::Error::Io(e)) => {
|
| Err(conduwuit::Error::Io(e)) => match e.kind() {
|
||||||
if matches!(
|
| std::io::ErrorKind::NotFound => return Err!(Request(NotFound("Media not found."))),
|
||||||
e.kind(),
|
| std::io::ErrorKind::PermissionDenied => {
|
||||||
std::io::ErrorKind::PermissionDenied | std::io::ErrorKind::NotFound
|
error!("Permission denied when trying to read file: {e:?}");
|
||||||
) {
|
return Err!(Request(Unknown("Unknown error when fetching file.")));
|
||||||
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.")));
|
|
||||||
},
|
},
|
||||||
| Err(_) => return Err!(Request(Unknown("Unknown error when fetching file."))),
|
| Err(_) => return Err!(Request(Unknown("Unknown error when fetching file."))),
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user