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,13 +27,12 @@ impl TempFileGuard {
|
||||||
|
|
||||||
impl Drop for TempFileGuard {
|
impl Drop for TempFileGuard {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
if self.0.exists() {
|
if self.0.exists()
|
||||||
if let Err(e) = std::fs::remove_file(&self.0) {
|
&& let Err(e) = std::fs::remove_file(&self.0) {
|
||||||
warn!("failed to clean up temp file {}: {e}", self.0.display());
|
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.
|
/// Generate a thumbnail for a media file and return the path to the thumbnail.
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -11,19 +11,20 @@ use uuid::Uuid;
|
||||||
/// forward-slash-separated relative path string. Falls back to the full path
|
/// 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 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.
|
/// string so internal callers that have not yet migrated still work.
|
||||||
|
#[must_use]
|
||||||
pub fn relativize_path(full_path: &Path, roots: &[PathBuf]) -> String {
|
pub fn relativize_path(full_path: &Path, roots: &[PathBuf]) -> String {
|
||||||
let mut best: Option<&PathBuf> = None;
|
let mut best: Option<&PathBuf> = None;
|
||||||
for root in roots {
|
for root in roots {
|
||||||
if full_path.starts_with(root) {
|
if full_path.starts_with(root) {
|
||||||
let is_longer = best
|
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 {
|
if is_longer {
|
||||||
best = Some(root);
|
best = Some(root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(root) = best {
|
if let Some(root) = best
|
||||||
if let Ok(rel) = full_path.strip_prefix(root) {
|
&& let Ok(rel) = full_path.strip_prefix(root) {
|
||||||
// Normalise to forward slashes on all platforms.
|
// Normalise to forward slashes on all platforms.
|
||||||
return rel
|
return rel
|
||||||
.components()
|
.components()
|
||||||
|
|
@ -31,7 +32,6 @@ pub fn relativize_path(full_path: &Path, roots: &[PathBuf]) -> String {
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join("/");
|
.join("/");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
full_path.to_string_lossy().into_owned()
|
full_path.to_string_lossy().into_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -269,6 +269,7 @@ impl MediaResponse {
|
||||||
/// matching root prefix from the path before serialization. Pass the
|
/// matching root prefix from the path before serialization. Pass the
|
||||||
/// configured root directories so that clients receive a relative path
|
/// configured root directories so that clients receive a relative path
|
||||||
/// (e.g. `"Music/song.mp3"`) rather than a full server filesystem 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 {
|
pub fn new(item: pinakes_core::model::MediaItem, roots: &[PathBuf]) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id: item.id.0.to_string(),
|
id: item.id.0.to_string(),
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ license = "EUPL-1.2"
|
||||||
kind = ["ui_page"]
|
kind = ["ui_page"]
|
||||||
|
|
||||||
[plugin.binary]
|
[plugin.binary]
|
||||||
wasm = "media_stats_ui.wasm"
|
wasm = "target/wasm32-unknown-unknown/release/media_stats_ui.wasm"
|
||||||
|
|
||||||
[capabilities]
|
[capabilities]
|
||||||
network = false
|
network = false
|
||||||
|
|
@ -19,7 +19,7 @@ read = []
|
||||||
write = []
|
write = []
|
||||||
|
|
||||||
[ui]
|
[ui]
|
||||||
required_endpoints = ["/api/v1/statistics", "/api/v1/media"]
|
required_endpoints = ["/api/v1/statistics", "/api/v1/media", "/api/v1/tags"]
|
||||||
|
|
||||||
# UI pages
|
# UI pages
|
||||||
[[ui.pages]]
|
[[ui.pages]]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue