pinakes-server: relativize media paths against configured root directories

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I9f113e6402030c46ad97f636985b5d6c6a6a6964
This commit is contained in:
raf 2026-03-11 17:07:17 +03:00
commit 9c67c81a79
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
11 changed files with 212 additions and 42 deletions

View file

@ -51,9 +51,14 @@ pub async fn search(
};
let results = state.storage.search(&request).await?;
let roots = state.config.read().await.directories.roots.clone();
Ok(Json(SearchResponse {
items: results.items.into_iter().map(MediaResponse::from).collect(),
items: results
.items
.into_iter()
.map(|item| MediaResponse::new(item, &roots))
.collect(),
total_count: results.total_count,
}))
}
@ -84,9 +89,14 @@ pub async fn search_post(
};
let results = state.storage.search(&request).await?;
let roots = state.config.read().await.directories.roots.clone();
Ok(Json(SearchResponse {
items: results.items.into_iter().map(MediaResponse::from).collect(),
items: results
.items
.into_iter()
.map(|item| MediaResponse::new(item, &roots))
.collect(),
total_count: results.total_count,
}))
}