[gnome-software] Ensure there is upgrade data when getting the list of distribution upgrades



commit 7b39e3dba9a2e187d4537a5da3f8867e37da9597
Author: Richard Hughes <richard hughsie com>
Date:   Wed Apr 20 14:22:25 2016 +0100

    Ensure there is upgrade data when getting the list of distribution upgrades
    
    This allows the end user to just open the updates panel to download the initial
    list of distro upgrades rather than waiting for a refresh or manually
    downloading all the pending updates.

 src/plugins/gs-plugin-fedora-distro-upgrades.c |   43 +++++++++++++++++------
 1 files changed, 32 insertions(+), 11 deletions(-)
---
diff --git a/src/plugins/gs-plugin-fedora-distro-upgrades.c b/src/plugins/gs-plugin-fedora-distro-upgrades.c
index 09ed353..6730d8d 100644
--- a/src/plugins/gs-plugin-fedora-distro-upgrades.c
+++ b/src/plugins/gs-plugin-fedora-distro-upgrades.c
@@ -149,19 +149,14 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
 }
 
 /**
- * gs_plugin_refresh:
+ * gs_plugin_fedora_distro_upgrades_refresh:
  */
-gboolean
-gs_plugin_refresh (GsPlugin *plugin,
-                  guint cache_age,
-                  GsPluginRefreshFlags flags,
-                  GCancellable *cancellable,
-                  GError **error)
+static gboolean
+gs_plugin_fedora_distro_upgrades_refresh (GsPlugin *plugin,
+                                         guint cache_age,
+                                         GCancellable *cancellable,
+                                         GError **error)
 {
-       /* only for update metadata, no stored state other than setup() */
-       if ((flags & GS_PLUGIN_REFRESH_FLAGS_METADATA) == 0)
-               return TRUE;
-
        /* check cache age */
        if (cache_age > 0) {
                guint tmp;
@@ -182,6 +177,25 @@ gs_plugin_refresh (GsPlugin *plugin,
                                        error);
 }
 
+/**
+ * gs_plugin_refresh:
+ */
+gboolean
+gs_plugin_refresh (GsPlugin *plugin,
+                  guint cache_age,
+                  GsPluginRefreshFlags flags,
+                  GCancellable *cancellable,
+                  GError **error)
+{
+       /* only for update metadata, no stored state other than setup() */
+       if ((flags & GS_PLUGIN_REFRESH_FLAGS_METADATA) == 0)
+               return TRUE;
+       return gs_plugin_fedora_distro_upgrades_refresh (plugin,
+                                                        cache_age,
+                                                        cancellable,
+                                                        error);
+}
+
 typedef enum {
        DISTRO_STATUS_ACTIVE,
        DISTRO_STATUS_DEVEL,
@@ -303,6 +317,13 @@ gs_plugin_add_distro_upgrades (GsPlugin *plugin,
        g_autofree gchar *data = NULL;
        g_autoptr(GPtrArray) distros = NULL;
 
+       /* just ensure there is any data, no matter how old */
+       if (!gs_plugin_fedora_distro_upgrades_refresh (plugin,
+                                                      G_MAXUINT,
+                                                      cancellable,
+                                                      error))
+               return FALSE;
+
        /* get cached file */
        if (!g_file_get_contents (plugin->priv->cachefn, &data, &len, error))
                return FALSE;


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