From 734ba9b0f14de9499979efa8680aa843add8d3a8 Mon Sep 17 00:00:00 2001 From: Paul Makles Date: Fri, 20 Dec 2024 16:42:32 +0000 Subject: [PATCH] fix: don't create "previews" of GIFs chore: change hardcoded cache limit (should be configed!) --- crates/core/database/src/models/file_hashes/model.rs | 2 +- crates/services/pigeon/src/api.rs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/core/database/src/models/file_hashes/model.rs b/crates/core/database/src/models/file_hashes/model.rs index c89951c5..46a249f0 100644 --- a/crates/core/database/src/models/file_hashes/model.rs +++ b/crates/core/database/src/models/file_hashes/model.rs @@ -45,7 +45,7 @@ auto_derived!( Image { width: isize, height: isize, - // animated: bool // TODO: https://docs.rs/image/latest/image/trait.AnimationDecoder.html + // animated: bool // TODO: https://docs.rs/image/latest/image/trait.AnimationDecoder.html for APNG support }, /// File is a video with specific dimensions Video { width: isize, height: isize }, diff --git a/crates/services/pigeon/src/api.rs b/crates/services/pigeon/src/api.rs index a446d3f3..e1f32673 100644 --- a/crates/services/pigeon/src/api.rs +++ b/crates/services/pigeon/src/api.rs @@ -64,7 +64,8 @@ lazy_static! { }) // TODO config // .max_capacity(1024 * 1024 * 1024) // Cache up to 1GiB in memory - .max_capacity(512 * 1024 * 1024) // Cache up to 512MiB in memory + // .max_capacity(512 * 1024 * 1024) // Cache up to 512MiB in memory + .max_capacity(2 * 1024 * 1024 * 1024) // Cache up to 2GiB in memory .time_to_live(Duration::from_secs(5 * 60)) // For up to 5 minutes .build(); } @@ -366,8 +367,8 @@ async fn fetch_preview( let hash = file.as_hash(&db).await?; - // Only process image files - if !matches!(hash.metadata, Metadata::Image { .. }) { + // Only process image files and don't process GIFs + if !matches!(hash.metadata, Metadata::Image { .. }) || hash.content_type == "image/gif" { return Ok( Redirect::permanent(&format!("/{tag}/{file_id}/{}", file.filename)).into_response(), );