aboutsummaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/routes/ui/assets.rs13
-rw-r--r--server/src/routes/ui/mod.rs1
2 files changed, 5 insertions, 9 deletions
diff --git a/server/src/routes/ui/assets.rs b/server/src/routes/ui/assets.rs
index ebd9453..d5d2839 100644
--- a/server/src/routes/ui/assets.rs
+++ b/server/src/routes/ui/assets.rs
@@ -19,7 +19,6 @@ pub use jellycommon::AssetRole;
use jellycommon::{AssetLocation, LocalTrack, PeopleGroup, SourceTrackKind, TrackSource};
use log::info;
use rocket::{get, http::ContentType, State};
-use std::{path::PathBuf, str::FromStr};
use tokio::fs::File;
#[get("/n/<id>/asset?<role>&<width>")]
@@ -51,7 +50,7 @@ pub async fn r_item_assets(
}
};
let asset = asset.unwrap_or(AssetLocation::Assets(
- PathBuf::from_str("fallback.avif").unwrap(),
+ format!("fallback-{:?}.avif", node.public.kind.unwrap_or_default()).into(),
));
Ok(asset_with_res(asset, width).await?)
}
@@ -78,13 +77,9 @@ pub async fn r_person_asset(
.get(index)
.ok_or(anyhow!("person does not exist"))?;
- let asset = app
- .person
- .asset
- .as_ref()
- .ok_or(anyhow!("no asset"))?
- .to_owned();
-
+ let asset = app.person.asset.to_owned().unwrap_or(AssetLocation::Assets(
+ format!("fallback-Person.avif").into(),
+ ));
Ok(asset_with_res(asset, width).await?)
}
diff --git a/server/src/routes/ui/mod.rs b/server/src/routes/ui/mod.rs
index af8cf10..3a006a9 100644
--- a/server/src/routes/ui/mod.rs
+++ b/server/src/routes/ui/mod.rs
@@ -68,6 +68,7 @@ pub struct CacheControlFile(File, String);
impl CacheControlFile {
pub async fn new(f: File) -> Self {
let meta = f.metadata().await.unwrap();
+ // TODO ETag should be cache path (or something like that) so federation clients can dedup assets
let modified = meta.mtime();
let mut h = DefaultHasher::new();
modified.hash(&mut h);