[gnome-software] Ensure web-apps are always installed with the right state



commit 24909943cc926f6bff957b544ecfbe29ba26187b
Author: Richard Hughes <richard hughsie com>
Date:   Thu Oct 31 08:22:15 2013 +0000

    Ensure web-apps are always installed with the right state
    
    We should always load the DB before any operation, otherwise we rely on
    GetInstalled() being called to create the results that could be used from Search()

 src/plugins/gs-plugin-epiphany.c |   36 +++++++++++++++++++++++++++++++++++-
 1 files changed, 35 insertions(+), 1 deletions(-)
---
diff --git a/src/plugins/gs-plugin-epiphany.c b/src/plugins/gs-plugin-epiphany.c
index 3b6fdb7..c76e9da 100644
--- a/src/plugins/gs-plugin-epiphany.c
+++ b/src/plugins/gs-plugin-epiphany.c
@@ -359,6 +359,14 @@ gs_plugin_app_install (GsPlugin *plugin,
        const gchar *filename;
        gboolean ret = TRUE;
 
+       /* already loaded */
+       if (g_once_init_enter (&plugin->priv->loaded)) {
+               ret = gs_plugin_epiphany_load_db (plugin, error);
+               g_once_init_leave (&plugin->priv->loaded, TRUE);
+               if (!ret)
+                       goto out;
+       }
+
        /* only process this app if was created by this plugin */
        if (g_strcmp0 (gs_app_get_management_plugin (app), "Epiphany") != 0)
                goto out;
@@ -386,6 +394,14 @@ gs_plugin_app_remove (GsPlugin *plugin,
        const gchar *filename;
        gboolean ret = TRUE;
 
+       /* already loaded */
+       if (g_once_init_enter (&plugin->priv->loaded)) {
+               ret = gs_plugin_epiphany_load_db (plugin, error);
+               g_once_init_leave (&plugin->priv->loaded, TRUE);
+               if (!ret)
+                       goto out;
+       }
+
        /* only process this app if was created by this plugin */
        if (g_strcmp0 (gs_app_get_management_plugin (app), "Epiphany") != 0)
                goto out;
@@ -410,6 +426,7 @@ gs_plugin_write_file (GsApp *app, const gchar *filename, GError **error)
 {
        GKeyFile *kf;
        const gchar *url;
+       gboolean enabled;
        gboolean ret;
        gchar *data;
        gchar *exec;
@@ -447,10 +464,19 @@ gs_plugin_write_file (GsApp *app, const gchar *filename, GError **error)
                                G_KEY_FILE_DESKTOP_GROUP,
                                G_KEY_FILE_DESKTOP_KEY_TERMINAL,
                                FALSE);
+       switch (gs_app_get_state (app)) {
+       case GS_APP_STATE_INSTALLING:
+       case GS_APP_STATE_INSTALLED:
+               enabled = TRUE;
+               break;
+       default:
+               enabled = FALSE;
+               break;
+       }
        g_key_file_set_boolean (kf,
                                G_KEY_FILE_DESKTOP_GROUP,
                                G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY,
-                               gs_app_get_state (app) == GS_APP_STATE_INSTALLED ? FALSE : TRUE);
+                               !enabled);
        g_key_file_set_string (kf,
                               G_KEY_FILE_DESKTOP_GROUP,
                               G_KEY_FILE_DESKTOP_KEY_TYPE,
@@ -668,6 +694,14 @@ gs_plugin_refine (GsPlugin *plugin,
        const gchar *tmp;
        gboolean ret = TRUE;
 
+       /* already loaded */
+       if (g_once_init_enter (&plugin->priv->loaded)) {
+               ret = gs_plugin_epiphany_load_db (plugin, error);
+               g_once_init_leave (&plugin->priv->loaded, TRUE);
+               if (!ret)
+                       goto out;
+       }
+
        for (l = list; l != NULL; l = l->next) {
                app = GS_APP (l->data);
                if (gs_app_get_id_kind (app) != GS_APP_ID_KIND_WEBAPP)


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