don't treat media file open errors other than NotFound as missing media

For example, we want to return M_UNKNOWN and propagate the error if
somebody set up their database directory permissions wrong.
This commit is contained in:
Olivia Lee 2024-12-13 01:18:09 -08:00
parent 67f0689d73
commit f216112455
No known key found for this signature in database
GPG key ID: 54D568A15B9CD1F9

View file

@ -392,8 +392,12 @@ impl Service {
key: &MediaFileKey,
) -> Result<Option<Vec<u8>>> {
let path = services().globals.get_media_file(key);
let Ok(mut file) = File::open(path).await else {
return Ok(None);
let mut file = match File::open(path).await {
Ok(file) => file,
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
return Ok(None)
}
Err(e) => return Err(e.into()),
};
let mut data = Vec::new();