From 15bbe9602b560c1f00a4ec8d64633d2964c3a815 Mon Sep 17 00:00:00 2001 From: Ryo Nakano Date: Fri, 27 Dec 2024 15:09:49 +0900 Subject: [PATCH 1/4] SystemUpdate: Get last refresh time via DBus --- src/Backends/SystemUpdate.vala | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Backends/SystemUpdate.vala b/src/Backends/SystemUpdate.vala index 22d2d59..d9d3c14 100644 --- a/src/Backends/SystemUpdate.vala +++ b/src/Backends/SystemUpdate.vala @@ -21,6 +21,7 @@ public class SettingsDaemon.Backends.SystemUpdate : Object { private PkUtils.CurrentState current_state; private UpdateDetails update_details; + private int64 last_refresh_time; private Pk.Task task; private Pk.PackageSack? available_updates = null; @@ -44,6 +45,8 @@ public class SettingsDaemon.Backends.SystemUpdate : Object { only_download = true }; + last_refresh_time = settings.get_int64 ("last-refresh-time"); + cancellable = new GLib.Cancellable (); try { @@ -97,7 +100,8 @@ public class SettingsDaemon.Backends.SystemUpdate : Object { try { available_updates = (yield task.get_updates_async (Pk.Filter.NONE, null, progress_callback)).get_package_sack (); - settings.set_int64 ("last-refresh-time", new DateTime.now_utc ().to_unix ()); + last_refresh_time = new DateTime.now_utc ().to_unix (); + settings.set_int64 ("last-refresh-time", last_refresh_time); if (available_updates == null || available_updates.get_size () == 0) { update_state (UP_TO_DATE); @@ -233,4 +237,8 @@ public class SettingsDaemon.Backends.SystemUpdate : Object { public async UpdateDetails get_update_details () throws DBusError, IOError { return update_details; } + + public async int64 get_last_refresh_time () throws DBusError, IOError { + return last_refresh_time; + } } From f6309e12f5981ccc42fd3a69a48d80650a5e49ee Mon Sep 17 00:00:00 2001 From: Ryo Nakano Date: Fri, 27 Dec 2024 18:51:34 +0900 Subject: [PATCH 2/4] Review variable declaration and substitution order --- src/Backends/SystemUpdate.vala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Backends/SystemUpdate.vala b/src/Backends/SystemUpdate.vala index d9d3c14..f17b639 100644 --- a/src/Backends/SystemUpdate.vala +++ b/src/Backends/SystemUpdate.vala @@ -21,11 +21,11 @@ public class SettingsDaemon.Backends.SystemUpdate : Object { private PkUtils.CurrentState current_state; private UpdateDetails update_details; - private int64 last_refresh_time; private Pk.Task task; private Pk.PackageSack? available_updates = null; private GLib.Cancellable cancellable; + private int64 last_refresh_time; construct { current_state = { @@ -45,10 +45,10 @@ public class SettingsDaemon.Backends.SystemUpdate : Object { only_download = true }; - last_refresh_time = settings.get_int64 ("last-refresh-time"); - cancellable = new GLib.Cancellable (); + last_refresh_time = settings.get_int64 ("last-refresh-time"); + try { var last_offline_results = Pk.offline_get_results (); From 713cdb3412217e211e712725d8a779b4a789f687 Mon Sep 17 00:00:00 2001 From: Ryo Nakano Date: Fri, 27 Dec 2024 20:05:30 +0900 Subject: [PATCH 3/4] Create private setter --- src/Backends/SystemUpdate.vala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Backends/SystemUpdate.vala b/src/Backends/SystemUpdate.vala index f17b639..a685d1a 100644 --- a/src/Backends/SystemUpdate.vala +++ b/src/Backends/SystemUpdate.vala @@ -100,8 +100,7 @@ public class SettingsDaemon.Backends.SystemUpdate : Object { try { available_updates = (yield task.get_updates_async (Pk.Filter.NONE, null, progress_callback)).get_package_sack (); - last_refresh_time = new DateTime.now_utc ().to_unix (); - settings.set_int64 ("last-refresh-time", last_refresh_time); + set_last_refresh_time (new DateTime.now_utc ().to_unix ()); if (available_updates == null || available_updates.get_size () == 0) { update_state (UP_TO_DATE); @@ -238,6 +237,11 @@ public class SettingsDaemon.Backends.SystemUpdate : Object { return update_details; } + private void set_last_refresh_time (int64 time) { + last_refresh_time = time; + settings.set_int64 ("last-refresh-time", last_refresh_time); + } + public async int64 get_last_refresh_time () throws DBusError, IOError { return last_refresh_time; } From 8144d08719da4474eba6ef3b71afc49e4f22b775 Mon Sep 17 00:00:00 2001 From: Ryo Nakano Date: Fri, 27 Dec 2024 21:11:20 +0900 Subject: [PATCH 4/4] Address changes request --- src/Backends/SystemUpdate.vala | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/Backends/SystemUpdate.vala b/src/Backends/SystemUpdate.vala index a685d1a..9b05382 100644 --- a/src/Backends/SystemUpdate.vala +++ b/src/Backends/SystemUpdate.vala @@ -25,7 +25,6 @@ public class SettingsDaemon.Backends.SystemUpdate : Object { private Pk.Task task; private Pk.PackageSack? available_updates = null; private GLib.Cancellable cancellable; - private int64 last_refresh_time; construct { current_state = { @@ -47,8 +46,6 @@ public class SettingsDaemon.Backends.SystemUpdate : Object { cancellable = new GLib.Cancellable (); - last_refresh_time = settings.get_int64 ("last-refresh-time"); - try { var last_offline_results = Pk.offline_get_results (); @@ -100,7 +97,7 @@ public class SettingsDaemon.Backends.SystemUpdate : Object { try { available_updates = (yield task.get_updates_async (Pk.Filter.NONE, null, progress_callback)).get_package_sack (); - set_last_refresh_time (new DateTime.now_utc ().to_unix ()); + settings.set_int64 ("last-refresh-time", new DateTime.now_utc ().to_unix ()); if (available_updates == null || available_updates.get_size () == 0) { update_state (UP_TO_DATE); @@ -237,12 +234,7 @@ public class SettingsDaemon.Backends.SystemUpdate : Object { return update_details; } - private void set_last_refresh_time (int64 time) { - last_refresh_time = time; - settings.set_int64 ("last-refresh-time", last_refresh_time); - } - public async int64 get_last_refresh_time () throws DBusError, IOError { - return last_refresh_time; + return settings.get_int64 ("last-refresh-time"); } }