split thumbnailing related into unit
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
167559bb27
commit
b903b46d16
3 changed files with 195 additions and 153 deletions
|
@ -12,6 +12,13 @@ pub(crate) struct Data {
|
|||
url_previews: Arc<Map>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(super) struct Metadata {
|
||||
pub(super) content_disposition: Option<String>,
|
||||
pub(super) content_type: Option<String>,
|
||||
pub(super) key: Vec<u8>,
|
||||
}
|
||||
|
||||
impl Data {
|
||||
pub(super) fn new(db: &Arc<Database>) -> Self {
|
||||
Self {
|
||||
|
@ -104,9 +111,7 @@ impl Data {
|
|||
Ok(keys)
|
||||
}
|
||||
|
||||
pub(super) fn search_file_metadata(
|
||||
&self, mxc: &str, width: u32, height: u32,
|
||||
) -> Result<(Option<String>, Option<String>, Vec<u8>)> {
|
||||
pub(super) fn search_file_metadata(&self, mxc: &str, width: u32, height: u32) -> Result<Metadata> {
|
||||
let mut prefix = mxc.as_bytes().to_vec();
|
||||
prefix.push(0xFF);
|
||||
prefix.extend_from_slice(&width.to_be_bytes());
|
||||
|
@ -141,7 +146,12 @@ impl Data {
|
|||
.map_err(|_| Error::bad_database("Content Disposition in mediaid_file is invalid unicode."))?,
|
||||
)
|
||||
};
|
||||
Ok((content_disposition, content_type, key))
|
||||
|
||||
Ok(Metadata {
|
||||
content_disposition,
|
||||
content_type,
|
||||
key,
|
||||
})
|
||||
}
|
||||
|
||||
/// Gets all the media keys in our database (this includes all the metadata
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue