diff options
author | metamuffin <metamuffin@disroot.org> | 2023-09-06 16:00:04 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-09-06 16:00:04 +0200 |
commit | cf5c9266ed512df9304e0e76d248eeab972e6665 (patch) | |
tree | 94ea6f52fc5ce41bdbffcefbab93ab2851557915 /server/src/routes/ui | |
parent | 93397112ce9d942d2da791d99640fabb7f7e31a9 (diff) | |
download | jellything-cf5c9266ed512df9304e0e76d248eeab972e6665.tar jellything-cf5c9266ed512df9304e0e76d248eeab972e6665.tar.bz2 jellything-cf5c9266ed512df9304e0e76d248eeab972e6665.tar.zst |
spawn thread for transcode
Diffstat (limited to 'server/src/routes/ui')
-rw-r--r-- | server/src/routes/ui/assets.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/server/src/routes/ui/assets.rs b/server/src/routes/ui/assets.rs index f2c3f3f..eae1b9b 100644 --- a/server/src/routes/ui/assets.rs +++ b/server/src/routes/ui/assets.rs @@ -8,6 +8,7 @@ use crate::{ routes::ui::{account::session::Session, error::MyError, CacheControlFile}, }; use anyhow::anyhow; +use async_std::task::spawn_blocking; use jellycommon::AssetLocation; use log::info; use rocket::{get, http::ContentType, FromFormField, State, UriDisplayQuery}; @@ -49,7 +50,8 @@ pub async fn r_item_assets( )); // fit the resolution into a finite set so the maximum cache is finite too. let width = 2usize.pow(width.unwrap_or(2048).clamp(128, 8196).ilog2()); - let path = jellytranscoder::image::transcode(asset, 50., 5, width)?; + let path = + spawn_blocking(move || jellytranscoder::image::transcode(asset, 50., 5, width)).await?; info!("loading asset from {path:?}"); Ok(( ContentType::AVIF, |