fix: don't create "previews" of GIFs

chore: change hardcoded cache limit (should be configed!)
This commit is contained in:
Paul Makles
2024-12-20 16:42:32 +00:00
parent ac731e547d
commit 7b15006a50
2 changed files with 5 additions and 4 deletions

View File

@@ -45,7 +45,7 @@ auto_derived!(
Image { Image {
width: isize, width: isize,
height: 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 /// File is a video with specific dimensions
Video { width: isize, height: isize }, Video { width: isize, height: isize },

View File

@@ -64,7 +64,8 @@ lazy_static! {
}) })
// TODO config // TODO config
// .max_capacity(1024 * 1024 * 1024) // Cache up to 1GiB in memory // .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 .time_to_live(Duration::from_secs(5 * 60)) // For up to 5 minutes
.build(); .build();
} }
@@ -366,8 +367,8 @@ async fn fetch_preview(
let hash = file.as_hash(&db).await?; let hash = file.as_hash(&db).await?;
// Only process image files // Only process image files and don't process GIFs
if !matches!(hash.metadata, Metadata::Image { .. }) { if !matches!(hash.metadata, Metadata::Image { .. }) || hash.content_type == "image/gif" {
return Ok( return Ok(
Redirect::permanent(&format!("/{tag}/{file_id}/{}", file.filename)).into_response(), Redirect::permanent(&format!("/{tag}/{file_id}/{}", file.filename)).into_response(),
); );