[gnome-software/fix-install-timestamp: 352/352] Set install-timestamp gsetting when we update or upgrade



commit 48483f97fb1aacf9ccbaa509775c148d4d4d0e86
Author: Umang Jain <umang endlessm com>
Date:   Mon Aug 20 16:42:00 2018 +0530

    Set install-timestamp gsetting when we update or upgrade
    
    install-timestamp is the gsetting which drives app-center
    notifications for pending updates. However, the logic for
    driving notifications was already present in gs-update-monitor
    (see no_updates_for_a_week) but it turns out that install-timestamp
    gsettings was not being set at appropriate places when the user
    updates or upgrades. We fill this gap by relying on plugin-loader's
    logic because that drives update or upgrades at a macro level.
    
    https://phabricator.endlessm.com/T22720

 lib/gs-plugin-loader.c |  7 +++++++
 lib/gs-utils.c         | 18 ++++++++++++++++++
 lib/gs-utils.h         |  1 +
 3 files changed, 26 insertions(+)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 68fff0e1..a931e553 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -3003,6 +3003,8 @@ gs_plugin_loader_generic_update (GsPluginLoader *plugin_loader,
                helper->anything_ran = TRUE;
                gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_FINISHED);
        }
+
+       gs_utils_update_install_timestamp (priv->settings);
        return TRUE;
 }
 
@@ -3069,6 +3071,11 @@ gs_plugin_loader_process_thread_cb (GTask *task,
                }
        }
 
+       if (action == GS_PLUGIN_ACTION_UPGRADE_TRIGGER) {
+               GsPluginLoaderPrivate *priv = gs_plugin_loader_get_instance_private (plugin_loader);
+               gs_utils_update_install_timestamp (priv->settings);
+       }
+
        /* remove from pending list */
        if (add_to_pending_array)
                gs_plugin_loader_pending_apps_remove (plugin_loader, helper);
diff --git a/lib/gs-utils.c b/lib/gs-utils.c
index 6e206caf..ee62e670 100644
--- a/lib/gs-utils.c
+++ b/lib/gs-utils.c
@@ -1200,4 +1200,22 @@ gs_utils_parse_evr (const gchar *evr,
        return TRUE;
 }
 
+/**
+ * gs_utils_update_install_timestamp:
+ *
+ * Sets the value of install-timestamp to current epoch. "install-timestamp" represents
+ * the last time we had an update or upgrade.
+ *
+ **/
+void
+gs_utils_update_install_timestamp (GSettings *settings)
+{
+       g_autoptr(GDateTime) now = NULL;
+
+       g_return_if_fail (settings != NULL);
+
+       now = g_date_time_new_now_local ();
+       g_settings_set (settings, "install-timestamp", "x", g_date_time_to_unix (now));
+}
+
 /* vim: set noexpandtab: */
diff --git a/lib/gs-utils.h b/lib/gs-utils.h
index 792a815e..d62ff616 100644
--- a/lib/gs-utils.h
+++ b/lib/gs-utils.h
@@ -103,6 +103,7 @@ gboolean     gs_utils_parse_evr             (const gchar     *evr,
                                                 gchar          **out_epoch,
                                                 gchar          **out_version,
                                                 gchar          **out_release);
+void            gs_utils_update_install_timestamp (GSettings *settings);
 
 G_END_DECLS
 


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