Change thumbnail requirements to be stricter

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 3 years ago
parent abf28402e6
commit 14397dd037

@ -1,6 +1,6 @@
[package] [package]
name = "mediarepo-api" name = "mediarepo-api"
version = "0.8.0" version = "0.9.0"
edition = "2018" edition = "2018"
license = "gpl-3" license = "gpl-3"

@ -97,11 +97,14 @@ fn thumb_scheme<R: Runtime>(app: &AppHandle<R>, request: &Request) -> Result<Res
((height as f32 * 0.8) as u32, (width as f32 * 0.8) as u32), ((height as f32 * 0.8) as u32, (width as f32 * 0.8) as u32),
((height as f32 * 1.2) as u32, (width as f32 * 1.2) as u32), ((height as f32 * 1.2) as u32, (width as f32 * 1.2) as u32),
))?; ))?;
let mime = thumb.mime_type.unwrap_or(String::from("image/png")); buf_state.add_entry(
buf_state.add_entry(request.uri().to_string(), mime.clone(), bytes.clone()); request.uri().to_string(),
thumb.mime_type.clone(),
bytes.clone(),
);
ResponseBuilder::new() ResponseBuilder::new()
.mimetype(&mime) .mimetype(&thumb.mime_type)
.status(200) .status(200)
.body(bytes) .body(bytes)
} }

@ -92,9 +92,9 @@ pub struct FileOSMetadata {
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ThumbnailMetadataResponse { pub struct ThumbnailMetadataResponse {
pub file_id: i64, pub file_id: i64,
pub height: i32, pub height: u32,
pub width: i32, pub width: u32,
pub mime_type: Option<String>, pub mime_type: String,
} }
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]

Loading…
Cancel
Save