diff options
author | metamuffin <metamuffin@disroot.org> | 2023-09-30 22:19:19 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-09-30 22:19:19 +0200 |
commit | d546caa3f5053ade763430490911fefd6257af9f (patch) | |
tree | 5834ea5aa352239ab9a3f57ee96dee20af51ca77 /server/src/routes/ui/assets.rs | |
parent | c8fe73a7b160d4ada3136de9c87ad2eb0091ff7b (diff) | |
download | jellything-d546caa3f5053ade763430490911fefd6257af9f.tar jellything-d546caa3f5053ade763430490911fefd6257af9f.tar.bz2 jellything-d546caa3f5053ade763430490911fefd6257af9f.tar.zst |
make cache async and fix parallel write bug
Diffstat (limited to 'server/src/routes/ui/assets.rs')
-rw-r--r-- | server/src/routes/ui/assets.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/server/src/routes/ui/assets.rs b/server/src/routes/ui/assets.rs index 992e3da..8c0496e 100644 --- a/server/src/routes/ui/assets.rs +++ b/server/src/routes/ui/assets.rs @@ -8,7 +8,7 @@ use crate::{ routes::ui::{account::session::Session, error::MyError, CacheControlFile}, }; use anyhow::anyhow; -use async_std::task::spawn_blocking; +use jellybase::AssetLocationExt; use jellycommon::AssetLocation; use log::info; use rocket::{get, http::ContentType, FromFormField, State, UriDisplayQuery}; @@ -53,11 +53,10 @@ 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 = - spawn_blocking(move || jellytranscoder::image::transcode(asset, 50., 5, width)).await?; + let path = jellytranscoder::image::transcode(asset, 50., 5, width).await?; info!("loading asset from {path:?}"); Ok(( ContentType::AVIF, - CacheControlFile::new(File::open(path).await?).await, + CacheControlFile::new(File::open(path.path()).await?).await, )) } |