From 4db44de88e0914d3fc7e591009881ede8157e305 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 28 Sep 2021 23:42:52 +0200 Subject: [PATCH] Use SetMust to set property value properly The actual value used on the Bus is not in the datadisk struct but somewhere in the implementation. Use SetMust to set the property. --- datadisk/datadisk.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/datadisk/datadisk.go b/datadisk/datadisk.go index e932054..58b8e5a 100644 --- a/datadisk/datadisk.go +++ b/datadisk/datadisk.go @@ -36,8 +36,8 @@ func GetDataMount() (*mountinfo.Mountinfo, error) { } type datadisk struct { - currentDisk string - conn *dbus.Conn + conn *dbus.Conn + props *prop.Properties } func (d datadisk) ChangeDevice(newDevice string) (bool, *dbus.Error) { @@ -79,7 +79,7 @@ func (d datadisk) ReloadDevice() (bool, *dbus.Error) { return false, dbus.MakeFailedError(err) } - d.currentDisk = mountInfo.MountSource + d.props.SetMust(ifaceName, "CurrentDevice", mountInfo.MountSource) return true, nil } @@ -100,14 +100,13 @@ func InitializeDBus(conn *dbus.Conn) { } d := datadisk{ - currentDisk: currentDisk, - conn: conn, + conn: conn, } propsSpec := map[string]map[string]*prop.Prop{ ifaceName: { "CurrentDevice": { - Value: &d.currentDisk, + Value: ¤tDisk, Writable: false, Emit: prop.EmitTrue, Callback: nil, @@ -118,6 +117,7 @@ func InitializeDBus(conn *dbus.Conn) { if err != nil { logging.Critical.Panic(err) } + d.props = props err = conn.Export(d, objectPath, ifaceName) if err != nil {