From cf5c9266ed512df9304e0e76d248eeab972e6665 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Wed, 6 Sep 2023 16:00:04 +0200 Subject: spawn thread for transcode --- server/src/routes/ui/assets.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'server/src') 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, -- cgit v1.2.3-70-g09d2