[gnome-software/1876-gnome-software-missing-an-install-upgrade-button-when-opening-an-rpm-file] snap: Check the alternative app list uses non-NULL app id



commit 4a9da6a7cb5104061eee1d2869a2995c3900ebe6
Author: Milan Crha <mcrha redhat com>
Date:   Thu Aug 25 12:34:30 2022 +0200

    snap: Check the alternative app list uses non-NULL app id
    
    The app id can be NULL for example when opening a local file.
    There is printed a runtime warning in such case, thus cover it
    and do not run the app list when the app id is not set.

 plugins/snap/gs-plugin-snap.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/plugins/snap/gs-plugin-snap.c b/plugins/snap/gs-plugin-snap.c
index d7d4162b3..e3c83a0f4 100644
--- a/plugins/snap/gs-plugin-snap.c
+++ b/plugins/snap/gs-plugin-snap.c
@@ -665,13 +665,18 @@ gs_plugin_snap_list_apps_async (GsPlugin              *plugin,
 
                        data->n_pending_ops++;
                        get_store_snap_async (self, client, snap_name, TRUE, cancellable, 
list_alternate_apps_snap_cb, g_steal_pointer (&task));
-               } else {
+               /* The id can be NULL for example for local package files */
+               } else if (gs_app_get_id (alternate_of) != NULL) {
                        data->n_pending_ops++;
                        snapd_client_find_section_async (client,
                                                         SNAPD_FIND_FLAGS_SCOPE_WIDE | 
SNAPD_FIND_FLAGS_MATCH_COMMON_ID,
                                                         NULL, gs_app_get_id (alternate_of),
                                                         cancellable,
                                                         list_alternate_apps_nonsnap_cb, g_steal_pointer 
(&task));
+               } else {
+                       g_clear_object (&data->results_list);
+                       g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+                                                "Unsupported app without id");
                }
 
                return;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]