Fix catalog refresh: handle null fields in AppImageHub feed JSON

This commit is contained in:
2026-02-28 00:46:39 +02:00
parent 5e1c10cea3
commit a4a7464354
2 changed files with 14 additions and 15 deletions

View File

@@ -152,17 +152,17 @@ fn fetch_appimage_hub() -> Result<Vec<CatalogApp>, CatalogError> {
let apps: Vec<CatalogApp> = feed.items.into_iter().filter_map(|item| {
// AppImageHub items need at least a name and a link
let name = item.name?;
let download_url = item.links.into_iter()
let download_url = item.links.unwrap_or_default().into_iter()
.find(|l| l.r#type == "Download")
.map(|l| l.url)?;
Some(CatalogApp {
name,
description: item.description,
categories: item.categories.unwrap_or_default(),
categories: item.categories.unwrap_or_default().into_iter().flatten().collect(),
latest_version: None,
download_url,
icon_url: item.icons.and_then(|icons| icons.into_iter().next()),
icon_url: item.icons.and_then(|icons| icons.into_iter().flatten().next()),
homepage: item.authors.and_then(|a| {
let first = a.into_iter().next()?;
if let Some(ref author_name) = first.name {
@@ -237,10 +237,10 @@ struct AppImageHubFeed {
struct AppImageHubItem {
name: Option<String>,
description: Option<String>,
categories: Option<Vec<String>>,
categories: Option<Vec<Option<String>>>,
authors: Option<Vec<AppImageHubAuthor>>,
links: Vec<AppImageHubLink>,
icons: Option<Vec<String>>,
links: Option<Vec<AppImageHubLink>>,
icons: Option<Vec<Option<String>>>,
}
#[derive(Debug, serde::Deserialize)]