pinakes-server: add MAX_OFFSET/MAX_LIMIT constants; centralize pagination bounds

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ib8227feb353cbbadc7f42fa5d29618e16a6a6964
This commit is contained in:
raf 2026-03-12 20:45:45 +03:00
commit c16fcb4a9b
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
6 changed files with 63 additions and 47 deletions

View file

@ -16,22 +16,23 @@ 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
.is_none_or(|b| root.components().count() > b.components().count());
let is_longer =
best.is_none_or(|b| root.components().count() > b.components().count());
if is_longer {
best = Some(root);
}
}
}
if let Some(root) = best
&& let Ok(rel) = full_path.strip_prefix(root) {
// Normalise to forward slashes on all platforms.
return rel
.components()
.map(|c| c.as_os_str().to_string_lossy())
.collect::<Vec<_>>()
.join("/");
}
&& let Ok(rel) = full_path.strip_prefix(root)
{
// Normalise to forward slashes on all platforms.
return rel
.components()
.map(|c| c.as_os_str().to_string_lossy())
.collect::<Vec<_>>()
.join("/");
}
full_path.to_string_lossy().into_owned()
}