treewide: cleanup

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ia01590cdeed872cc8ebd16f6ca95f3cc6a6a6964
This commit is contained in:
raf 2026-03-11 17:23:51 +03:00
commit 185e3b562a
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
16 changed files with 258 additions and 219 deletions

View file

@ -15,7 +15,8 @@ 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());
let is_longer = best
.map_or(true, |b| root.components().count() > b.components().count());
if is_longer {
best = Some(root);
}
@ -268,10 +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.
pub fn new(
item: pinakes_core::model::MediaItem,
roots: &[PathBuf],
) -> Self {
pub fn new(item: pinakes_core::model::MediaItem, roots: &[PathBuf]) -> Self {
Self {
id: item.id.0.to_string(),
path: relativize_path(&item.path, roots),
@ -358,10 +356,7 @@ mod tests {
#[test]
fn relativize_path_empty_roots_returns_full() {
let path = Path::new("/home/user/music/song.mp3");
assert_eq!(
relativize_path(path, &[]),
"/home/user/music/song.mp3"
);
assert_eq!(relativize_path(path, &[]), "/home/user/music/song.mp3");
}
#[test]