From 3d18113c5924c45156dd36bb39f11612edb5fe01 Mon Sep 17 00:00:00 2001 From: Mikael Carneholm Date: Sat, 30 May 2026 11:47:03 +0200 Subject: [PATCH 1/3] Update the state to UP_TO_DATE when PackageKit reports no offline updates available --- src/Backends/SystemUpdate.vala | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/Backends/SystemUpdate.vala b/src/Backends/SystemUpdate.vala index 4a110f47..f7a7de66 100644 --- a/src/Backends/SystemUpdate.vala +++ b/src/Backends/SystemUpdate.vala @@ -14,6 +14,7 @@ public class SettingsDaemon.Backends.SystemUpdate : Object { } private const string NOTIFICATION_ID = "system-update"; + private const string PREPARED_UPDATE_PATH = "/var/lib/PackageKit/prepared-update"; public signal void state_changed (); @@ -25,6 +26,7 @@ public class SettingsDaemon.Backends.SystemUpdate : Object { private Pk.Task task; private Pk.PackageSack? available_updates = null; private GLib.Cancellable cancellable; + private GLib.FileMonitor? prepared_update_monitor = null; construct { current_state = { @@ -58,6 +60,26 @@ public class SettingsDaemon.Backends.SystemUpdate : Object { } catch (Error e) { warning ("Couldn't determine last offline results: %s", e.message); } + try { + prepared_update_monitor = File.new_for_path (PREPARED_UPDATE_PATH).monitor_file (NONE); + prepared_update_monitor.changed.connect ((file, other_file, event) => revalidate_restart_required ()); + } catch (Error e) { + warning ("Couldn't monitor prepared offline updates: %s", e.message); + } + } + + private void revalidate_restart_required () { + if (current_state.state != RESTART_REQUIRED) { + return; + } + + try { + if (Pk.offline_get_prepared_ids ().length == 0) { + update_state (UP_TO_DATE); + } + } catch (Error e) { + warning ("Failed to get offline prepared ids: %s", e.message); + } } public async void check_for_updates (bool force, bool notify) throws DBusError, IOError { @@ -65,7 +87,10 @@ public class SettingsDaemon.Backends.SystemUpdate : Object { return; } - if (current_state.state != UP_TO_DATE && current_state.state != AVAILABLE && !force) { + if (current_state.state != UP_TO_DATE && + current_state.state != AVAILABLE && + current_state.state != RESTART_REQUIRED && + !force) { return; } @@ -235,6 +260,7 @@ public class SettingsDaemon.Backends.SystemUpdate : Object { } public async PkUtils.CurrentState get_current_state () throws DBusError, IOError { + revalidate_restart_required (); return current_state; } From f6894e008f36db6b68937c1bf032048cd8facd48 Mon Sep 17 00:00:00 2001 From: Mikael Carneholm Date: Sat, 30 May 2026 12:40:45 +0200 Subject: [PATCH 2/3] Just let the update-monitor fire check_for_updates() --- src/Backends/SystemUpdate.vala | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/src/Backends/SystemUpdate.vala b/src/Backends/SystemUpdate.vala index f7a7de66..8b44809e 100644 --- a/src/Backends/SystemUpdate.vala +++ b/src/Backends/SystemUpdate.vala @@ -14,7 +14,6 @@ public class SettingsDaemon.Backends.SystemUpdate : Object { } private const string NOTIFICATION_ID = "system-update"; - private const string PREPARED_UPDATE_PATH = "/var/lib/PackageKit/prepared-update"; public signal void state_changed (); @@ -61,36 +60,19 @@ public class SettingsDaemon.Backends.SystemUpdate : Object { warning ("Couldn't determine last offline results: %s", e.message); } try { - prepared_update_monitor = File.new_for_path (PREPARED_UPDATE_PATH).monitor_file (NONE); - prepared_update_monitor.changed.connect ((file, other_file, event) => revalidate_restart_required ()); + prepared_update_monitor = Pk.offline_get_prepared_monitor (); + prepared_update_monitor.changed.connect (() => check_for_updates.begin (true, true)); } catch (Error e) { warning ("Couldn't monitor prepared offline updates: %s", e.message); } } - private void revalidate_restart_required () { - if (current_state.state != RESTART_REQUIRED) { - return; - } - - try { - if (Pk.offline_get_prepared_ids ().length == 0) { - update_state (UP_TO_DATE); - } - } catch (Error e) { - warning ("Failed to get offline prepared ids: %s", e.message); - } - } - public async void check_for_updates (bool force, bool notify) throws DBusError, IOError { if (SettingsDaemon.Utils.is_running_in_demo_mode () && !force) { return; } - if (current_state.state != UP_TO_DATE && - current_state.state != AVAILABLE && - current_state.state != RESTART_REQUIRED && - !force) { + if (current_state.state != UP_TO_DATE && current_state.state != AVAILABLE && !force) { return; } @@ -260,7 +242,6 @@ public class SettingsDaemon.Backends.SystemUpdate : Object { } public async PkUtils.CurrentState get_current_state () throws DBusError, IOError { - revalidate_restart_required (); return current_state; } From 5e59e10e9156ea53c0498a471e3f6bf508becefe Mon Sep 17 00:00:00 2001 From: Mikael Carneholm Date: Sun, 31 May 2026 22:15:32 +0200 Subject: [PATCH 3/3] Add missing line break Co-authored-by: Leonhard --- src/Backends/SystemUpdate.vala | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Backends/SystemUpdate.vala b/src/Backends/SystemUpdate.vala index 8b44809e..a5d6b9d9 100644 --- a/src/Backends/SystemUpdate.vala +++ b/src/Backends/SystemUpdate.vala @@ -59,6 +59,7 @@ public class SettingsDaemon.Backends.SystemUpdate : Object { } catch (Error e) { warning ("Couldn't determine last offline results: %s", e.message); } + try { prepared_update_monitor = Pk.offline_get_prepared_monitor (); prepared_update_monitor.changed.connect (() => check_for_updates.begin (true, true));