daemon/sysroot: Emit UPDATED signal for configs

Let's also make sure we refresh `RPMOSTreeOS` objects when configs
changed. Specifically, what they export to their D-Bus interfaces may be
dependent on daemon settings, as is the case with auto-updates.

We might want to decouple this into two separate signals in the future
(one for sysroot changes, and one for config changes), though given that
only `RPMOSTreeOS` listens for `UPDATED` right now, we can just get away
with a single one for the time being.

Closes: #1261
Approved by: cgwalters
This commit is contained in:
Jonathan Lebon 2018-02-17 18:59:05 +00:00 committed by Atomic Bot
parent df80e15002
commit 55040a56ad
3 changed files with 14 additions and 3 deletions

View File

@ -409,6 +409,7 @@ handle_unregister_client (RPMOSTreeSysroot *object,
return TRUE; return TRUE;
} }
/* remap relevant daemon configs to D-Bus properties */
static gboolean static gboolean
reset_config_properties (RpmostreedSysroot *self, reset_config_properties (RpmostreedSysroot *self,
GError **error) GError **error)
@ -438,9 +439,15 @@ handle_reload_config (RPMOSTreeSysroot *object,
if (changed && !reset_config_properties (self, error)) if (changed && !reset_config_properties (self, error))
goto out; goto out;
if (!rpmostreed_sysroot_reload (self, error)) gboolean sysroot_changed;
if (!rpmostreed_sysroot_reload (self, &sysroot_changed, error))
goto out; goto out;
/* also send an UPDATED signal if configs changed to cause OS interfaces to reload; we do
* it here if not done already in `rpmostreed_sysroot_reload` */
if (changed && !sysroot_changed)
g_signal_emit (self, signals[UPDATED], 0);
rpmostree_sysroot_complete_reload_config (object, invocation); rpmostree_sysroot_complete_reload_config (object, invocation);
out: out:
if (local_error) if (local_error)
@ -683,6 +690,7 @@ rpmostreed_sysroot_class_init (RpmostreedSysrootClass *klass)
gboolean gboolean
rpmostreed_sysroot_reload (RpmostreedSysroot *self, rpmostreed_sysroot_reload (RpmostreedSysroot *self,
gboolean *out_changed,
GError **error) GError **error)
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
@ -695,6 +703,8 @@ rpmostreed_sysroot_reload (RpmostreedSysroot *self,
goto out; goto out;
ret = TRUE; ret = TRUE;
if (out_changed)
*out_changed = did_change;
out: out:
if (ret && did_change) if (ret && did_change)
g_signal_emit (self, signals[UPDATED], 0); g_signal_emit (self, signals[UPDATED], 0);
@ -713,7 +723,7 @@ on_deploy_changed (GFileMonitor *monitor,
if (event_type == G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED) if (event_type == G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED)
{ {
if (!rpmostreed_sysroot_reload (self, &error)) if (!rpmostreed_sysroot_reload (self, NULL, &error))
goto out; goto out;
} }

View File

@ -36,6 +36,7 @@ gboolean rpmostreed_sysroot_populate (RpmostreedSysroot *self
GCancellable *cancellable, GCancellable *cancellable,
GError **error); GError **error);
gboolean rpmostreed_sysroot_reload (RpmostreedSysroot *self, gboolean rpmostreed_sysroot_reload (RpmostreedSysroot *self,
gboolean *out_changed,
GError **error); GError **error);
OstreeSysroot * rpmostreed_sysroot_get_root (RpmostreedSysroot *self); OstreeSysroot * rpmostreed_sysroot_get_root (RpmostreedSysroot *self);

View File

@ -326,7 +326,7 @@ transaction_execute_done_cb (GObject *source_object,
success = g_task_propagate_boolean (G_TASK (result), &local_error); success = g_task_propagate_boolean (G_TASK (result), &local_error);
if (success) if (success)
{ {
if (!rpmostreed_sysroot_reload (rpmostreed_sysroot_get (), &local_error)) if (!rpmostreed_sysroot_reload (rpmostreed_sysroot_get (), NULL, &local_error))
success = FALSE; success = FALSE;
} }