[gnome-software] Fix Flatpak store initialization



commit 917cfe01350da0deda009b4f14fd366e4ac503a2
Author: Joaquim Rocha <jrocha endlessm com>
Date:   Mon Dec 12 21:02:07 2016 +0100

    Fix Flatpak store initialization
    
    When GNOME Software is started without the refresh being called, e.g.
    when lauching with the "--mode overview" option, the Flatpak plugin
    tries to use the AppStream store without it being populated with the
    available apps.
    
    This patch populates the store during "setup", ensuring that in any way
    that GNOME Software is started the Flatpak plugin should be have access
    to its apps.

 src/plugins/gs-flatpak.c |   27 ++++++++-------------------
 1 files changed, 8 insertions(+), 19 deletions(-)
---
diff --git a/src/plugins/gs-flatpak.c b/src/plugins/gs-flatpak.c
index 3e20e6b..bf818b4 100644
--- a/src/plugins/gs-flatpak.c
+++ b/src/plugins/gs-flatpak.c
@@ -408,11 +408,19 @@ gboolean
 gs_flatpak_setup (GsFlatpak *self, GCancellable *cancellable, GError **error)
 {
        g_autoptr(AsProfileTask) ptask = NULL;
+       g_autoptr(GError) error_md = NULL;
 
        ptask = as_profile_start_literal (gs_plugin_get_profile (self->plugin),
                                          "flatpak::setup");
        g_assert (ptask != NULL);
 
+       if (!gs_flatpak_refresh_appstream (self, G_MAXUINT, 0,
+                                          cancellable,
+                                          &error_md)) {
+               g_warning ("failed to get initial available data on setup: %s",
+                          error_md->message);
+       }
+
        /* load just the wildcards */
        if (!as_store_load (self->store,
                            AS_STORE_LOAD_FLAG_ONLY_MERGE_APPS |
@@ -715,18 +723,9 @@ gs_flatpak_add_installed (GsFlatpak *self, GsAppList *list,
                          GCancellable *cancellable,
                          GError **error)
 {
-       g_autoptr(GError) error_md = NULL;
        g_autoptr(GPtrArray) xrefs = NULL;
        guint i;
 
-       /* if we've never ever run before, get the AppStream data */
-       if (!gs_flatpak_refresh_appstream (self, G_MAXUINT, 0,
-                                          cancellable,
-                                          &error_md)) {
-               g_warning ("failed to get initial available data: %s",
-                          error_md->message);
-       }
-
        /* get apps and runtimes */
        xrefs = flatpak_installation_list_installed_refs (self->installation,
                                                          cancellable, error);
@@ -2686,16 +2685,6 @@ gs_flatpak_search (GsFlatpak *self,
                   GCancellable *cancellable,
                   GError **error)
 {
-       g_autoptr(GError) error_md = NULL;
-
-       /* if we've never ever run before, get the AppStream data */
-       if (!gs_flatpak_refresh_appstream (self, G_MAXUINT, 0,
-                                          cancellable,
-                                          &error_md)) {
-               g_warning ("failed to get initial available data: %s",
-                          error_md->message);
-       }
-
        return gs_appstream_store_search (self->plugin, self->store,
                                          values, list,
                                          cancellable, error);


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