diff options
| author | metamuffin <metamuffin@disroot.org> | 2026-02-21 03:27:59 +0100 |
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2026-02-21 03:27:59 +0100 |
| commit | a7e9d52efd1dba23a43f13d0eb9bb2236d1de74c (patch) | |
| tree | 8eb04b29acd56c5718481d76b62542a0f2103594 | |
| parent | deaa85b6215a9d643834a00f64202b0efc758b76 (diff) | |
| download | jellything-a7e9d52efd1dba23a43f13d0eb9bb2236d1de74c.tar jellything-a7e9d52efd1dba23a43f13d0eb9bb2236d1de74c.tar.bz2 jellything-a7e9d52efd1dba23a43f13d0eb9bb2236d1de74c.tar.zst | |
fix image transcode on evloop thread
| -rw-r--r-- | server/src/ui/assets.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/server/src/ui/assets.rs b/server/src/ui/assets.rs index c956672..91bb5e2 100644 --- a/server/src/ui/assets.rs +++ b/server/src/ui/assets.rs @@ -8,6 +8,7 @@ use crate::{request_info::RequestInfo, responders::cache::CacheControlImage}; use anyhow::Context; use rocket::{get, http::ContentType}; use std::path::PathBuf; +use tokio::task::spawn_blocking; pub const AVIF_QUALITY: u32 = 70; pub const AVIF_SPEED: u8 = 5; @@ -23,9 +24,12 @@ pub async fn r_image( // fit the resolution into a finite set so the maximum cache is finite too. let width = 2usize.pow(size.clamp(128, 2048).ilog2()); - let encoded = + let encoded = spawn_blocking(move || { jellytranscoder::image::transcode(&ri.state.cache, &path, AVIF_QUALITY, AVIF_SPEED, width) - .context("transcoding asset")?; + .context("transcoding asset") + }) + .await + .unwrap()?; Ok((ContentType::AVIF, CacheControlImage(encoded))) } |