[gnome-software] Do a second resolve pass for unadopted wildcard apps



commit e09c9c5dcf020347ce1b9c04e7650f4f2c18777d
Author: Richard Hughes <richard hughsie com>
Date:   Thu Jun 2 20:27:50 2016 +0100

    Do a second resolve pass for unadopted wildcard apps
    
    If a plugin runs before appstream that adds a GsApp with MATCH_ANY_PREFIX,
    appstream helpfully converts that app to something that is recognised.
    
    This will not be adopted, so in this case we have to do a 2nd pass of the
    adopt+refine through the plugins again to ensure the management plugin is set.

 src/gs-plugin-loader.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 7991d61..9394b55 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -431,6 +431,7 @@ gs_plugin_loader_run_refine (GsPluginLoader *plugin_loader,
                             GCancellable *cancellable,
                             GError **error)
 {
+       gboolean has_match_any_prefix = FALSE;
        gboolean ret;
        guint i;
        g_autoptr(GsAppList) freeze_list = NULL;
@@ -453,7 +454,36 @@ gs_plugin_loader_run_refine (GsPluginLoader *plugin_loader,
                                                    flags,
                                                    cancellable,
                                                    error);
+       if (!ret)
+               goto out;
+
+       /* second pass for any unadopted apps in the wildcard state */
+       for (i = 0; i < gs_app_list_length (list); i++) {
+               GsApp *app = gs_app_list_index (list, i);
+
+               /* not needing to resolve */
+               if (!gs_app_has_quirk (app, AS_APP_QUIRK_MATCH_ANY_PREFIX))
+                       continue;
+               if (gs_app_get_management_plugin (app) != NULL)
+                       continue;
 
+               /* this doesn't make sense outside the plugin loader */
+               gs_app_remove_quirk (app, AS_APP_QUIRK_MATCH_ANY_PREFIX);
+               has_match_any_prefix = TRUE;
+       }
+       if (has_match_any_prefix) {
+               g_debug ("2nd resolve pass for unadopted wildcards");
+               ret = gs_plugin_loader_run_refine_internal (plugin_loader,
+                                                           function_name_parent,
+                                                           list,
+                                                           flags,
+                                                           cancellable,
+                                                           error);
+               if (!ret)
+                       goto out;
+       }
+
+out:
        /* now emit all the changed signals */
        for (i = 0; i < gs_app_list_length (freeze_list); i++) {
                GsApp *app = gs_app_list_index (freeze_list, i);


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