[gnome-software/wip/kalev/gnome-3-22-prep: 19/52] Do not unconditionally refine AppStream apps in the cache



commit 9983f5f6c1c01aafe7de79804a614de420bd4a16
Author: Richard Hughes <richard hughsie com>
Date:   Wed Sep 28 09:45:18 2016 +0100

    Do not unconditionally refine AppStream apps in the cache
    
    If the app is in the cache it does not need to be refined, so avoid doing a
    ton of string processing for no reason. This speeds up search performance.
    
    (cherry picked from commit 0270f8a6430befb24d11172c47beb1dfe8d0d445)

 src/plugins/gs-appstream.c        |   12 +++++++-----
 src/plugins/gs-appstream.h        |    3 ++-
 src/plugins/gs-flatpak.c          |    4 +++-
 src/plugins/gs-plugin-appstream.c |   14 +++++++-------
 4 files changed, 19 insertions(+), 14 deletions(-)
---
diff --git a/src/plugins/gs-appstream.c b/src/plugins/gs-appstream.c
index cfdd490..e530f8d 100644
--- a/src/plugins/gs-appstream.c
+++ b/src/plugins/gs-appstream.c
@@ -28,7 +28,7 @@
 #define        GS_APPSTREAM_MAX_SCREENSHOTS    5
 
 GsApp *
-gs_appstream_create_app (GsPlugin *plugin, AsApp *item)
+gs_appstream_create_app (GsPlugin *plugin, AsApp *item, GError **error)
 {
        const gchar *unique_id = as_app_get_unique_id (item);
        GsApp *app = gs_plugin_cache_lookup (plugin, unique_id);
@@ -36,6 +36,8 @@ gs_appstream_create_app (GsPlugin *plugin, AsApp *item)
                app = gs_app_new (as_app_get_id (item));
                gs_app_set_metadata (app, "GnomeSoftware::Creator",
                                     gs_plugin_get_name (plugin));
+               if (!gs_appstream_refine_app (plugin, app, item, error))
+                       return NULL;
                gs_plugin_cache_add (plugin, unique_id, app);
        }
        return app;
@@ -756,8 +758,8 @@ gs_appstream_store_search_item (GsPlugin *plugin,
                return TRUE;
 
        /* create app */
-       app = gs_appstream_create_app (plugin, item);
-       if (!gs_appstream_refine_app (plugin, app, item, error))
+       app = gs_appstream_create_app (plugin, item, error);
+       if (app == NULL)
                return FALSE;
        gs_app_set_match_value (app, match_value);
        gs_app_list_add (list, app);
@@ -889,8 +891,8 @@ gs_appstream_store_add_category_apps (GsPlugin *plugin,
                                continue;
 
                        /* add all the data we can */
-                       app = gs_appstream_create_app (plugin, item);
-                       if (!gs_appstream_refine_app (plugin, app, item, error))
+                       app = gs_appstream_create_app (plugin, item, error);
+                       if (app == NULL)
                                return FALSE;
                        gs_app_list_add (list, app);
                }
diff --git a/src/plugins/gs-appstream.h b/src/plugins/gs-appstream.h
index 0a19fcf..88e8afc 100644
--- a/src/plugins/gs-appstream.h
+++ b/src/plugins/gs-appstream.h
@@ -27,7 +27,8 @@
 G_BEGIN_DECLS
 
 GsApp          *gs_appstream_create_app                (GsPlugin       *plugin,
-                                                        AsApp          *item);
+                                                        AsApp          *item,
+                                                        GError         **error);
 gboolean        gs_appstream_refine_app                (GsPlugin       *plugin,
                                                         GsApp          *app,
                                                         AsApp          *item,
diff --git a/src/plugins/gs-flatpak.c b/src/plugins/gs-flatpak.c
index a2b9713..fb1bdb7 100644
--- a/src/plugins/gs-flatpak.c
+++ b/src/plugins/gs-flatpak.c
@@ -1658,7 +1658,9 @@ gs_flatpak_refine_wildcard (GsFlatpak *self, GsApp *app,
                /* new app */
                g_debug ("found %s for wildcard %s",
                         as_app_get_unique_id (item), id);
-               new = gs_appstream_create_app (self->plugin, item);
+               new = gs_appstream_create_app (self->plugin, item, NULL);
+               if (new == NULL)
+                       return FALSE;
                gs_app_set_scope (new, self->scope);
                if (!gs_flatpak_refine_app (self, new, flags, cancellable, error))
                        return FALSE;
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index f85f405..0adf108 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -407,11 +407,11 @@ gs_plugin_add_distro_upgrades (GsPlugin *plugin,
                        continue;
 
                /* create */
-               app = gs_appstream_create_app (plugin, item);
+               app = gs_appstream_create_app (plugin, item, error);
+               if (app == NULL)
+                       return FALSE;
                gs_app_set_kind (app, AS_APP_KIND_OS_UPGRADE);
                gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
-               if (!gs_appstream_refine_app (plugin, app, item, error))
-                       return FALSE;
                gs_app_list_add (list, app);
        }
        return TRUE;
@@ -475,8 +475,8 @@ gs_plugin_refine_wildcard (GsPlugin *plugin,
                /* new app */
                g_debug ("found %s for wildcard %s",
                         as_app_get_id (item), id);
-               new = gs_appstream_create_app (plugin, item);
-               if (!gs_appstream_refine_app (plugin, new, item, error))
+               new = gs_appstream_create_app (plugin, item, error);
+               if (new == NULL)
                        return FALSE;
                gs_app_list_add (list, new);
        }
@@ -538,8 +538,8 @@ gs_plugin_add_installed (GsPlugin *plugin,
                item = g_ptr_array_index (array, i);
                if (as_app_get_state (item) == AS_APP_STATE_INSTALLED) {
                        g_autoptr(GsApp) app = NULL;
-                       app = gs_appstream_create_app (plugin, item);
-                       if (!gs_appstream_refine_app (plugin, app, item, error))
+                       app = gs_appstream_create_app (plugin, item, error);
+                       if (app == NULL)
                                return FALSE;
                        gs_app_list_add (list, app);
                }


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