[gnome-software/gnome-42: 3/4] gs-appstream: Fix requires relations being ignored if no recommends exist
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-42: 3/4] gs-appstream: Fix requires relations being ignored if no recommends exist
- Date: Wed, 25 May 2022 15:46:00 +0000 (UTC)
commit c35586ddb4476e3f672a2499f7e7565a8a257447
Author: Philip Withnall <pwithnall endlessos org>
Date: Wed May 25 12:13:17 2022 +0100
gs-appstream: Fix requires relations being ignored if no recommends exist
Spotted by Milan Crha in
https://gitlab.gnome.org/GNOME/gnome-software/-/merge_requests/1379#note_1463083.
Any `<requires>` elements were being ignored if no `<recommends>`
elements were present, as the query for the latter would have returned
`G_IO_ERROR_NOT_FOUND`.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
lib/gs-appstream.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/lib/gs-appstream.c b/lib/gs-appstream.c
index 4b8894927..16a402c33 100644
--- a/lib/gs-appstream.c
+++ b/lib/gs-appstream.c
@@ -922,29 +922,29 @@ gs_appstream_refine_app_relations (GsApp *app,
/* find any recommends */
recommends = xb_node_query (component, "recommends", 0, &error_local);
- if (recommends == NULL) {
- if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
- return TRUE;
+ if (recommends == NULL &&
+ !g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) {
g_propagate_error (error, g_steal_pointer (&error_local));
return FALSE;
}
- for (guint i = 0; i < recommends->len; i++) {
+ for (guint i = 0; recommends != NULL && i < recommends->len; i++) {
XbNode *recommend = g_ptr_array_index (recommends, i);
if (!gs_appstream_refine_app_relation (app, recommend, AS_RELATION_KIND_RECOMMENDS, error))
return FALSE;
}
+ g_clear_error (&error_local);
+
/* find any requires */
requires = xb_node_query (component, "requires", 0, &error_local);
- if (requires == NULL) {
- if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
- return TRUE;
+ if (requires == NULL &&
+ !g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) {
g_propagate_error (error, g_steal_pointer (&error_local));
return FALSE;
}
- for (guint i = 0; i < requires->len; i++) {
+ for (guint i = 0; requires != NULL && i < requires->len; i++) {
XbNode *require = g_ptr_array_index (requires, i);
if (!gs_appstream_refine_app_relation (app, require, AS_RELATION_KIND_REQUIRES, error))
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]