diff options
author | metamuffin <metamuffin@disroot.org> | 2023-06-16 18:18:53 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-06-16 18:18:53 +0200 |
commit | ed2b5a8911e46e9cc7242aff09b8fa61f210d185 (patch) | |
tree | 72c071c0103b865d05516fa581be10342f0ad1f3 /server/src/library.rs | |
parent | 846fe07c2d083fa1015a9ef55b440a83def6e8b8 (diff) | |
download | jellything-ed2b5a8911e46e9cc7242aff09b8fa61f210d185.tar jellything-ed2b5a8911e46e9cc7242aff09b8fa61f210d185.tar.bz2 jellything-ed2b5a8911e46e9cc7242aff09b8fa61f210d185.tar.zst |
asset api
Diffstat (limited to 'server/src/library.rs')
-rw-r--r-- | server/src/library.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/server/src/library.rs b/server/src/library.rs index 330f382..ffd8b4a 100644 --- a/server/src/library.rs +++ b/server/src/library.rs @@ -14,6 +14,8 @@ use std::{ sync::Arc, }; +use crate::{routes::ui::node::AssetRole, CONF}; + pub struct Library { pub root: Arc<Node>, pub root_path: PathBuf, @@ -183,6 +185,22 @@ impl Node { bail!("did somebody really put a fifo or socket in the library?!") } } + + pub fn get_asset(&self, library: &Library, role: AssetRole) -> PathBuf { + let path = match role { + AssetRole::Backdrop => self + .common() + .backdrop + .clone() + .or_else(|| self.common().poster.clone()), + AssetRole::Poster => self.common().poster.clone(), + }; + if let Some(p) = path { + library.root_path.join(p) + } else { + CONF.asset_path.join("fallback.jpeg") + } + } } impl Item { |