chore: fix clippy lints; format
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ib3d98a81c7e41054d27e617394bef63c6a6a6964
This commit is contained in:
parent
489e55d0b4
commit
ad6d0b646f
3 changed files with 9 additions and 9 deletions
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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]]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue