aboutsummaryrefslogtreecommitdiff
path: root/server/src/routes/ui
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-09-30 22:19:19 +0200
committermetamuffin <metamuffin@disroot.org>2023-09-30 22:19:19 +0200
commitd546caa3f5053ade763430490911fefd6257af9f (patch)
tree5834ea5aa352239ab9a3f57ee96dee20af51ca77 /server/src/routes/ui
parentc8fe73a7b160d4ada3136de9c87ad2eb0091ff7b (diff)
downloadjellything-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')
-rw-r--r--server/src/routes/ui/assets.rs7
-rw-r--r--server/src/routes/ui/layout.rs2
2 files changed, 4 insertions, 5 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,
))
}
diff --git a/server/src/routes/ui/layout.rs b/server/src/routes/ui/layout.rs
index fdda3e4..1c47247 100644
--- a/server/src/routes/ui/layout.rs
+++ b/server/src/routes/ui/layout.rs
@@ -16,7 +16,7 @@ use crate::{
},
uri,
};
-use async_std::task::block_on;
+use futures::executor::block_on;
use jellybase::CONF;
use markup::{DynRender, Render};
use rocket::{