[gnome-software] gs-loading-page: Update software cache on first run



commit 9b0bbccdb6884606eeee062c78f24c3cf63cf5c7
Author: Philip Withnall <withnall endlessm com>
Date:   Mon Jul 8 21:40:46 2019 +0100

    gs-loading-page: Update software cache on first run
    
    Currently, the software cache is only updated on startup if it’s empty.
    However, this is not helpful in situations where the cache is present
    but very old when gnome-software is first started. This can happen on
    machines shipped with Endless OS (which pre-seeds the software cache)
    which have sat in storage for a while before being booted for the first
    time by their user. In that situation, old apps would be shown, which is
    confusing and not a good user experience.
    
    As a compromise, update the app cache if it’s older than 24h when
    gnome-software is first started. On subsequent starts, revert to the old
    behaviour of only updating the cache if it’s missing.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>

 src/gs-loading-page.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/src/gs-loading-page.c b/src/gs-loading-page.c
index 08d1e86d..db0a598e 100644
--- a/src/gs-loading-page.c
+++ b/src/gs-loading-page.c
@@ -114,11 +114,25 @@ gs_loading_page_load (GsLoadingPage *self)
 {
        GsLoadingPagePrivate *priv = gs_loading_page_get_instance_private (self);
        g_autoptr(GsPluginJob) plugin_job = NULL;
+       g_autoptr(GSettings) settings = NULL;
+       guint64 cache_age;
+
+       /* Ensure that at least some metadata of any age is present, and also
+        * spin up the plugins enough as to prime caches. If this is the first
+        * run of gnome-software, set the cache age to 24h to ensure that the
+        * metadata is refreshed if, for example, this is the first boot of a
+        * computer which has been in storage (after manufacture) for a while.
+        * Otherwise, set the cache age to the maximum, to only refresh if we’re
+        * completely missing app data — otherwise, we want to start up as fast
+        * as possible. */
+       settings = g_settings_new ("org.gnome.software");
+       if (g_settings_get_boolean (settings, "first-run"))
+               cache_age = 60 * 60 * 24;  /* 24 hours */
+       else
+               cache_age = G_MAXUINT;
 
-       /* ensure that at least some metadata of any age is present, and also
-        * spin up the plugins enough as to prime caches */
        plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_REFRESH,
-                                        "age", (guint64) G_MAXUINT,
+                                        "age", cache_age,
                                         NULL);
        gs_plugin_loader_job_process_async (priv->plugin_loader, plugin_job,
                                        priv->cancellable,


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