[gnome-software] Use gs_plugin_setup() in the xdg-app plugin



commit 2d471b4870d873f09ffc5e223cff45b51d05bb83
Author: Richard Hughes <richard hughsie com>
Date:   Wed Apr 13 20:38:38 2016 +0100

    Use gs_plugin_setup() in the xdg-app plugin
    
    This makes things waaay more threadsafe and is less code.

 src/plugins/gs-plugin-xdg-app.c |   61 ++++-----------------------------------
 1 files changed, 6 insertions(+), 55 deletions(-)
---
diff --git a/src/plugins/gs-plugin-xdg-app.c b/src/plugins/gs-plugin-xdg-app.c
index 2b04305..5e6e1c0 100644
--- a/src/plugins/gs-plugin-xdg-app.c
+++ b/src/plugins/gs-plugin-xdg-app.c
@@ -264,20 +264,15 @@ gs_plugin_refresh_appstream (GsPlugin *plugin,
 }
 
 /**
- * gs_plugin_ensure_installation:
+ * gs_plugin_setup:
  */
-static gboolean
-gs_plugin_ensure_installation (GsPlugin *plugin,
-                              GCancellable *cancellable,
-                              GError **error)
+gboolean
+gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
 {
        g_autofree gchar *install_path = NULL;
        g_autoptr(AsProfileTask) ptask = NULL;
        g_autoptr(GFile) install_file = NULL;
 
-       if (plugin->priv->installation != NULL)
-               return TRUE;
-
        /* If we're running INSIDE the xdg-app environment we'll have the
         * env var XDG_DATA_HOME set to "~/.var/app/org.gnome.Software/data"
         * so specify the path manually to get the real data */
@@ -473,10 +468,6 @@ gs_plugin_add_installed (GsPlugin *plugin,
        g_autoptr(GPtrArray) xrefs = NULL;
        guint i;
 
-       /* ensure we can set up the repo */
-       if (!gs_plugin_ensure_installation (plugin, cancellable, error))
-               return FALSE;
-
        /* if we've never ever run before, get the AppStream data */
        if (!gs_plugin_refresh_appstream (plugin,
                                          G_MAXUINT,
@@ -524,10 +515,6 @@ gs_plugin_add_sources (GsPlugin *plugin,
        g_autoptr(GPtrArray) xremotes = NULL;
        guint i;
 
-       /* ensure we can set up the repo */
-       if (!gs_plugin_ensure_installation (plugin, cancellable, error))
-               return FALSE;
-
        xremotes = xdg_app_installation_list_remotes (plugin->priv->installation,
                                                      cancellable,
                                                      error);
@@ -572,10 +559,6 @@ gs_plugin_add_updates (GsPlugin *plugin,
        guint i;
        g_autoptr(GPtrArray) xrefs = NULL;
 
-       /* ensure we can set up the repo */
-       if (!gs_plugin_ensure_installation (plugin, cancellable, error))
-               return FALSE;
-
        /* get all the installed apps (no network I/O) */
        xrefs = xdg_app_installation_list_installed_refs (plugin->priv->installation,
                                                          cancellable,
@@ -630,10 +613,6 @@ gs_plugin_refresh (GsPlugin *plugin,
        guint i;
        g_autoptr(GPtrArray) xrefs = NULL;
 
-       /* ensure we can set up the repo */
-       if (!gs_plugin_ensure_installation (plugin, cancellable, error))
-               return FALSE;
-
        /* update AppStream metadata */
        if (flags & GS_PLUGIN_REFRESH_FLAGS_METADATA) {
                if (!gs_plugin_refresh_appstream (plugin, cache_age,
@@ -700,12 +679,8 @@ gs_plugin_refine_item_origin_ui (GsPlugin *plugin,
        if (origin != NULL)
                return TRUE;
 
-       /* ensure we can set up the repo */
-       ptask = as_profile_start_literal (plugin->profile, "xdg-app::refine-origin-ui");
-       if (!gs_plugin_ensure_installation (plugin, cancellable, error))
-               return FALSE;
-
        /* find list of remotes */
+       ptask = as_profile_start_literal (plugin->profile, "xdg-app::refine-origin-ui");
        xremotes = xdg_app_installation_list_remotes (plugin->priv->installation,
                                                      cancellable,
                                                      error);
@@ -740,12 +715,8 @@ gs_plugin_refine_item_origin (GsPlugin *plugin,
        if (gs_app_get_origin (app) != NULL)
                return TRUE;
 
-       /* ensure we can set up the repo */
-       ptask = as_profile_start_literal (plugin->profile, "xdg-app::refine-origin");
-       if (!gs_plugin_ensure_installation (plugin, cancellable, error))
-               return FALSE;
-
        /* ensure metadata exists */
+       ptask = as_profile_start_literal (plugin->profile, "xdg-app::refine-origin");
        if (!gs_plugin_refine_item_metadata (plugin, app, cancellable, error))
                return FALSE;
 
@@ -1198,11 +1169,7 @@ gs_plugin_refine_app (GsPlugin *plugin,
                      GsPluginRefineFlags flags,
                      GCancellable *cancellable,
                      GError **error)
-{
-       /* ensure we can set up the repo */
-       if (!gs_plugin_ensure_installation (plugin, cancellable, error))
-               return FALSE;
-       return gs_plugin_xdg_app_refine_app (plugin, app, flags, cancellable, error);
+{      return gs_plugin_xdg_app_refine_app (plugin, app, flags, cancellable, error);
 }
 
 /**
@@ -1220,10 +1187,6 @@ gs_plugin_launch (GsPlugin *plugin,
        if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
                return TRUE;
 
-       /* ensure we can set up the repo */
-       if (!gs_plugin_ensure_installation (plugin, cancellable, error))
-               return FALSE;
-
        branch = gs_app_get_xdgapp_branch (app);
        if (branch == NULL)
                branch = "master";
@@ -1251,10 +1214,6 @@ gs_plugin_app_remove (GsPlugin *plugin,
        if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
                return TRUE;
 
-       /* ensure we can set up the repo */
-       if (!gs_plugin_ensure_installation (plugin, cancellable, error))
-               return FALSE;
-
        /* use helper: FIXME: new()&ref? */
        helper.app = app;
        helper.plugin = plugin;
@@ -1286,10 +1245,6 @@ gs_plugin_app_install (GsPlugin *plugin,
        if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
                return TRUE;
 
-       /* ensure we can set up the repo */
-       if (!gs_plugin_ensure_installation (plugin, cancellable, error))
-               return FALSE;
-
        /* ensure we have metadata and state */
        if (!gs_plugin_xdg_app_refine_app (plugin, app, 0, cancellable, error))
                return FALSE;
@@ -1387,10 +1342,6 @@ gs_plugin_update_app (GsPlugin *plugin,
        if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
                return TRUE;
 
-       /* ensure we can set up the repo */
-       if (!gs_plugin_ensure_installation (plugin, cancellable, error))
-               return FALSE;
-
        /* use helper: FIXME: new()&ref? */
        helper.app = app;
        helper.plugin = plugin;


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