fix ordering panic

This commit is contained in:
JMARyA 2024-08-02 21:06:37 +02:00
parent 589a596a30
commit 33e23eaba0
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263

View file

@ -26,11 +26,14 @@ pub async fn albums_route(artist_id: &str, lib: &State<Libary>) -> FallibleApiRe
} }
fn sort_by_tracknumber(a: &serde_json::Value, b: &serde_json::Value) -> Ordering { fn sort_by_tracknumber(a: &serde_json::Value, b: &serde_json::Value) -> Ordering {
a.get("tracknumber") let order = (|| {
.unwrap() Some(
.as_i64() a.get("tracknumber")?
.unwrap() .as_i64()?
.cmp(&b.get("tracknumber").unwrap().as_i64().unwrap()) .cmp(&b.get("tracknumber")?.as_i64()?),
)
})();
order.unwrap_or(Ordering::Equal)
} }
#[get("/album/<album_id>/cover")] #[get("/album/<album_id>/cover")]