[gnome-software] Do not use gs_plugin_cache_invalidate()



commit 0d6df413e33b93aae5469890f3a6d6645b254ff5
Author: Richard Hughes <richard hughsie com>
Date:   Sat Jun 11 22:02:50 2016 +0100

    Do not use gs_plugin_cache_invalidate()
    
    This is only need when reloading the plugins (which we don't support) and
    removing the invalidate means the UI does not get decoupled when AppStream
    files are changed.

 src/gs-plugin.c                                |    7 ++++++-
 src/plugins/gs-plugin-appstream.c              |    3 ---
 src/plugins/gs-plugin-fedora-distro-upgrades.c |    3 ---
 src/plugins/gs-plugin-shell-extensions.c       |   22 ++++++++++++----------
 src/plugins/gs-plugin-systemd-updates.c        |    3 ---
 5 files changed, 18 insertions(+), 20 deletions(-)
---
diff --git a/src/gs-plugin.c b/src/gs-plugin.c
index 86a162b..0f0b84b 100644
--- a/src/gs-plugin.c
+++ b/src/gs-plugin.c
@@ -998,7 +998,12 @@ gs_plugin_cache_add (GsPlugin *plugin, const gchar *key, GsApp *app)
  * @plugin: a #GsPlugin
  *
  * Invalidate the per-plugin cache by marking all entries as invalid.
- * This is optional, and the plugin can evict the cache whenever it likes.
+ * This is optional, and the plugin can evict the cache whenever it
+ * likes. Using this function may mean the front-end and the plugin
+ * may be operating on a different GsApp with the same cache ID.
+ *
+ * Most plugins do not need to call this funtion; if a suitable cache
+ * key is being used the old cache item can remain.
  **/
 void
 gs_plugin_cache_invalidate (GsPlugin *plugin)
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index 279eafd..8e5846f 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -45,9 +45,6 @@ gs_plugin_appstream_store_changed_cb (AsStore *store, GsPlugin *plugin)
 {
        g_debug ("AppStream metadata changed");
 
-       /* cache no longer valid */
-       gs_plugin_cache_invalidate (plugin);
-
        /* this is not strictly true, but it causes all the UI to be reloaded
         * which is what we really want */
        if (!gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_RUNNING_OTHER))
diff --git a/src/plugins/gs-plugin-fedora-distro-upgrades.c b/src/plugins/gs-plugin-fedora-distro-upgrades.c
index 6575e55..3fd78b6 100644
--- a/src/plugins/gs-plugin-fedora-distro-upgrades.c
+++ b/src/plugins/gs-plugin-fedora-distro-upgrades.c
@@ -64,9 +64,6 @@ gs_plugin_fedora_distro_upgrades_changed_cb (GFileMonitor *monitor,
 {
        GsPlugin *plugin = GS_PLUGIN (user_data);
 
-       /* cache no longer valid */
-       gs_plugin_cache_invalidate (plugin);
-
        /* only reload the update list if the plugin is NOT running itself
         * and the time since it ran is greater than 5 seconds (inotify FTW) */
        if (gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_RUNNING_SELF)) {
diff --git a/src/plugins/gs-plugin-shell-extensions.c b/src/plugins/gs-plugin-shell-extensions.c
index daae0fd..7d05602 100644
--- a/src/plugins/gs-plugin-shell-extensions.c
+++ b/src/plugins/gs-plugin-shell-extensions.c
@@ -90,8 +90,9 @@ gs_plugin_shell_extensions_id_from_uuid (const gchar *uuid)
        return g_strdup_printf ("%s.shell-extension", uuid);
 }
 
-static GsApp *
+static gboolean
 gs_plugin_shell_extensions_add_app (GsPlugin *plugin,
+                                   GsApp *app,
                                    const gchar *uuid,
                                    GVariantIter *iter,
                                    GError **error)
@@ -102,11 +103,10 @@ gs_plugin_shell_extensions_add_app (GsPlugin *plugin,
        g_autofree gchar *id = NULL;
        g_autofree gchar *id_prefix = NULL;
        g_autoptr(AsIcon) ic = NULL;
-       g_autoptr(GsApp) app = NULL;
 
        id = gs_plugin_shell_extensions_id_from_uuid (uuid);
        id_prefix = g_strdup_printf ("user:%s", id);
-       app = gs_app_new (id_prefix);
+       gs_app_set_id (app, id_prefix);
        gs_app_set_metadata (app, "GnomeSoftware::Creator",
                             gs_plugin_get_name (plugin));
        gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
@@ -123,7 +123,7 @@ gs_plugin_shell_extensions_add_app (GsPlugin *plugin,
                                                 NULL);
                        tmp2 = as_markup_convert_simple (tmp1, error);
                        if (tmp2 == NULL)
-                               return NULL;
+                               return FALSE;
                        gs_app_set_description (app, GS_APP_QUALITY_NORMAL, tmp2);
                        continue;
                }
@@ -207,7 +207,7 @@ gs_plugin_shell_extensions_add_app (GsPlugin *plugin,
        gs_app_add_category (app, "Addons");
        gs_app_add_category (app, "ShellExtensions");
 
-       return g_steal_pointer (&app);
+       return TRUE;
 }
 
 static void
@@ -218,7 +218,7 @@ gs_plugin_shell_extensions_changed_cb (GDBusProxy *proxy,
                                       GsPlugin *plugin)
 {
        if (g_strcmp0 (signal_name, "ExtensionStatusChanged") == 0)
-               gs_plugin_cache_invalidate (plugin);
+               gs_plugin_updates_changed (plugin);
 }
 
 gboolean
@@ -258,6 +258,7 @@ gs_plugin_add_installed (GsPlugin *plugin,
 {
        GsPluginData *priv = gs_plugin_get_data (plugin);
        GVariantIter *ext_iter;
+       gboolean ret;
        gchar *ext_uuid;
        g_autoptr(GVariantIter) iter = NULL;
        g_autoptr(GVariant) retval = NULL;
@@ -280,17 +281,18 @@ gs_plugin_add_installed (GsPlugin *plugin,
 
                /* search in the cache */
                app = gs_plugin_cache_lookup (plugin, ext_uuid);
-               if (app != NULL) {
+               if (app == NULL) {
+                       app = gs_app_new (NULL);
                        gs_app_list_add (list, app);
-                       continue;
                }
 
                /* parse the data into an GsApp */
-               app = gs_plugin_shell_extensions_add_app (plugin,
+               ret = gs_plugin_shell_extensions_add_app (plugin,
+                                                         app,
                                                          ext_uuid,
                                                          ext_iter,
                                                          error);
-               if (app == NULL)
+               if (!ret)
                        return FALSE;
 
                /* save in the cache */
diff --git a/src/plugins/gs-plugin-systemd-updates.c b/src/plugins/gs-plugin-systemd-updates.c
index 8fb1c5b..c059359 100644
--- a/src/plugins/gs-plugin-systemd-updates.c
+++ b/src/plugins/gs-plugin-systemd-updates.c
@@ -58,9 +58,6 @@ gs_plugin_systemd_updates_changed_cb (GFileMonitor *monitor,
 {
        GsPlugin *plugin = GS_PLUGIN (user_data);
 
-       /* cache no longer valid */
-       gs_plugin_cache_invalidate (plugin);
-
        /* update UI */
        gs_plugin_updates_changed (plugin);
 }


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