chore: fix clippy lints; format

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ib3d98a81c7e41054d27e617394bef63c6a6a6964
This commit is contained in:
raf 2026-03-11 21:29:24 +03:00
commit ad6d0b646f
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
3 changed files with 9 additions and 9 deletions

View file

@ -27,12 +27,11 @@ 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());
}
}
}
}
/// Generate a thumbnail for a media file and return the path to the thumbnail.

View file

@ -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::<Vec<_>>()
.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(),

View file

@ -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]]