messing with trait objects

This commit is contained in:
Timo Kösters 2022-10-05 12:45:54 +02:00 committed by Nyaaori
parent 8708cd3b63
commit face766e0f
No known key found for this signature in database
GPG key ID: E7819C3ED4D1F82E
61 changed files with 623 additions and 544 deletions

View file

@ -1,3 +1,5 @@
use ruma::api::client::error::ErrorKind;
use crate::{database::KeyValueDatabase, service, Error, utils, Result};
impl service::media::Data for KeyValueDatabase {
@ -33,7 +35,7 @@ impl service::media::Data for KeyValueDatabase {
prefix.extend_from_slice(&0_u32.to_be_bytes()); // Height = 0 if it's not a thumbnail
prefix.push(0xff);
let (key, _) = self.mediaid_file.scan_prefix(prefix).next().ok_or(Error::NotFound)?;
let (key, _) = self.mediaid_file.scan_prefix(prefix).next().ok_or(Error::BadRequest(ErrorKind::NotFound, "Media not found"))?;
let mut parts = key.rsplit(|&b| b == 0xff);