Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use SetMust to set property value properly #37

Merged
merged 1 commit into from
Sep 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions datadisk/datadisk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}

Expand All @@ -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: &currentDisk,
Writable: false,
Emit: prop.EmitTrue,
Callback: nil,
Expand All @@ -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 {
Expand Down