[gnome-software] update monitor: Only update the update check timestamp when it succeeds



commit ec43729c479a88ef37dfdb1026a80fc838209ec0
Author: Kalev Lember <klember redhat com>
Date:   Tue Jul 3 09:54:37 2018 +0200

    update monitor: Only update the update check timestamp when it succeeds
    
    When we do background update checks and fail to do a check (e.g. because
    there's no network access), don't update the saved timestamp. This
    ensures that we:
    
     a) continue trying to get updates and not give up for the day, and
     b) don't show misleading "Last checked: " text on the updates page on
        first launch when there's no network connection
    
    Fixes https://gitlab.gnome.org/GNOME/gnome-software/issues/17

 src/gs-update-monitor.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/src/gs-update-monitor.c b/src/gs-update-monitor.c
index 3441b161..1a95586d 100644
--- a/src/gs-update-monitor.c
+++ b/src/gs-update-monitor.c
@@ -398,6 +398,7 @@ refresh_cache_finished_cb (GObject *object,
                           gpointer data)
 {
        GsUpdateMonitor *monitor = data;
+       g_autoptr(GDateTime) now = NULL;
        g_autoptr(GError) error = NULL;
 
        if (!gs_plugin_loader_job_action_finish (GS_PLUGIN_LOADER (object), res, &error)) {
@@ -405,6 +406,12 @@ refresh_cache_finished_cb (GObject *object,
                        g_warning ("failed to refresh the cache: %s", error->message);
                return;
        }
+
+       /* update the last checked timestamp */
+       now = g_date_time_new_now_local ();
+       g_settings_set (monitor->settings, "check-timestamp", "x",
+                       g_date_time_to_unix (now));
+
        get_updates (monitor);
 }
 
@@ -424,7 +431,6 @@ check_updates (GsUpdateMonitor *monitor)
        gint64 tmp;
        gboolean refresh_on_metered;
        g_autoptr(GDateTime) last_refreshed = NULL;
-       g_autoptr(GDateTime) now_refreshed = NULL;
        g_autoptr(GsPluginJob) plugin_job = NULL;
        GsPluginRefreshFlags refresh_flags = GS_PLUGIN_REFRESH_FLAGS_METADATA;
 
@@ -481,10 +487,6 @@ check_updates (GsUpdateMonitor *monitor)
        }
 
        g_debug ("Daily update check due");
-       now_refreshed = g_date_time_new_now_local ();
-       g_settings_set (monitor->settings, "check-timestamp", "x",
-                       g_date_time_to_unix (now_refreshed));
-
        if (gs_plugin_loader_get_allow_updates (monitor->plugin_loader) &&
            g_settings_get_boolean (monitor->settings, "download-updates")) {
                g_debug ("Refreshing for metadata and payload");


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