From ad6d0b646fdee052a98e668a81d0dad976d1ad59 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 11 Mar 2026 21:29:24 +0300 Subject: [PATCH] chore: fix clippy lints; format Signed-off-by: NotAShelf Change-Id: Ib3d98a81c7e41054d27e617394bef63c6a6a6964 --- crates/pinakes-core/src/thumbnail.rs | 5 ++--- crates/pinakes-server/src/dto/media.rs | 9 +++++---- examples/plugins/media-stats-ui/plugin.toml | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/pinakes-core/src/thumbnail.rs b/crates/pinakes-core/src/thumbnail.rs index e221c76..7e3b799 100644 --- a/crates/pinakes-core/src/thumbnail.rs +++ b/crates/pinakes-core/src/thumbnail.rs @@ -27,11 +27,10 @@ impl TempFileGuard { impl Drop for TempFileGuard { fn drop(&mut self) { - if self.0.exists() { - if let Err(e) = std::fs::remove_file(&self.0) { + if self.0.exists() + && let Err(e) = std::fs::remove_file(&self.0) { warn!("failed to clean up temp file {}: {e}", self.0.display()); } - } } } diff --git a/crates/pinakes-server/src/dto/media.rs b/crates/pinakes-server/src/dto/media.rs index dc1a155..e404776 100644 --- a/crates/pinakes-server/src/dto/media.rs +++ b/crates/pinakes-server/src/dto/media.rs @@ -11,19 +11,20 @@ use uuid::Uuid; /// forward-slash-separated relative path string. Falls back to the full path /// string when no root matches. If `roots` is empty, returns the full path as a /// string so internal callers that have not yet migrated still work. +#[must_use] pub fn relativize_path(full_path: &Path, roots: &[PathBuf]) -> String { let mut best: Option<&PathBuf> = None; for root in roots { if full_path.starts_with(root) { let is_longer = best - .map_or(true, |b| root.components().count() > b.components().count()); + .is_none_or(|b| root.components().count() > b.components().count()); if is_longer { best = Some(root); } } } - if let Some(root) = best { - if let Ok(rel) = full_path.strip_prefix(root) { + if let Some(root) = best + && let Ok(rel) = full_path.strip_prefix(root) { // Normalise to forward slashes on all platforms. return rel .components() @@ -31,7 +32,6 @@ pub fn relativize_path(full_path: &Path, roots: &[PathBuf]) -> String { .collect::>() .join("/"); } - } full_path.to_string_lossy().into_owned() } @@ -269,6 +269,7 @@ impl MediaResponse { /// matching root prefix from the path before serialization. Pass the /// configured root directories so that clients receive a relative path /// (e.g. `"Music/song.mp3"`) rather than a full server filesystem path. + #[must_use] pub fn new(item: pinakes_core::model::MediaItem, roots: &[PathBuf]) -> Self { Self { id: item.id.0.to_string(), diff --git a/examples/plugins/media-stats-ui/plugin.toml b/examples/plugins/media-stats-ui/plugin.toml index f65def5..0e8116a 100644 --- a/examples/plugins/media-stats-ui/plugin.toml +++ b/examples/plugins/media-stats-ui/plugin.toml @@ -9,7 +9,7 @@ license = "EUPL-1.2" kind = ["ui_page"] [plugin.binary] -wasm = "media_stats_ui.wasm" +wasm = "target/wasm32-unknown-unknown/release/media_stats_ui.wasm" [capabilities] network = false @@ -19,7 +19,7 @@ read = [] write = [] [ui] -required_endpoints = ["/api/v1/statistics", "/api/v1/media"] +required_endpoints = ["/api/v1/statistics", "/api/v1/media", "/api/v1/tags"] # UI pages [[ui.pages]]