[gnome-software/gnome-3-22] Use the unique-id if the key argument for the cache is NULL



commit 40638276ebbbd56198240bceefd8632979155a71
Author: Richard Hughes <richard hughsie com>
Date:   Fri Sep 9 10:27:28 2016 +0100

    Use the unique-id if the key argument for the cache is NULL
    
    (cherry picked from commit 52747c5252c1b4e0913a160869552aaf48b1fcda)

 src/gs-plugin.c            |    7 +++++--
 src/plugins/gs-appstream.c |    2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/src/gs-plugin.c b/src/gs-plugin.c
index 6a2f6f1..054d8b7 100644
--- a/src/gs-plugin.c
+++ b/src/gs-plugin.c
@@ -1210,7 +1210,7 @@ gs_plugin_cache_lookup (GsPlugin *plugin, const gchar *key)
 /**
  * gs_plugin_cache_add:
  * @plugin: a #GsPlugin
- * @key: a string
+ * @key: a string, or %NULL if the unique ID should be used
  * @app: a #GsApp
  *
  * Adds an application to the per-plugin cache. This is optional,
@@ -1225,9 +1225,12 @@ gs_plugin_cache_add (GsPlugin *plugin, const gchar *key, GsApp *app)
        g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&priv->cache_mutex);
 
        g_return_if_fail (GS_IS_PLUGIN (plugin));
-       g_return_if_fail (key != NULL);
        g_return_if_fail (GS_IS_APP (app));
 
+       /* default */
+       if (key == NULL)
+               key = gs_app_get_unique_id (app);
+
        /* global, so using internal unique_id */
        if (gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_GLOBAL_CACHE)) {
                if (!as_utils_unique_id_valid (key)) {
diff --git a/src/plugins/gs-appstream.c b/src/plugins/gs-appstream.c
index 03e8658..5850dd0 100644
--- a/src/plugins/gs-appstream.c
+++ b/src/plugins/gs-appstream.c
@@ -303,7 +303,7 @@ gs_appstream_create_runtime (GsPlugin *plugin,
                return g_object_ref (app_cache);
 
        /* save in the cache */
-       gs_plugin_cache_add (plugin, gs_app_get_unique_id (app), app);
+       gs_plugin_cache_add (plugin, NULL, app);
        return g_steal_pointer (&app);
 }
 


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