Mqtt: fix error handling for tree cleanup
This commit is contained in:
parent
0ece8c6e20
commit
83720c6f1a
2 changed files with 5 additions and 2 deletions
|
|
@ -123,7 +123,7 @@ func (m *Client) ConnectionHandler(client paho.Client) {
|
|||
|
||||
// Cleanup recursively removes a topic
|
||||
func (m *Client) Cleanup(topic string, retained bool) error {
|
||||
if m.Client.Subscribe(topic, m.Qos, func(c paho.Client, msg paho.Message) {
|
||||
if !m.Client.Subscribe(topic, m.Qos, func(c paho.Client, msg paho.Message) {
|
||||
if len(msg.Payload()) == 0 {
|
||||
return
|
||||
}
|
||||
|
|
@ -136,7 +136,7 @@ func (m *Client) Cleanup(topic string, retained bool) error {
|
|||
|
||||
time.Sleep(time.Second)
|
||||
|
||||
if m.Client.Unsubscribe(topic).WaitTimeout(request.Timeout) {
|
||||
if !m.Client.Unsubscribe(topic).WaitTimeout(request.Timeout) {
|
||||
return api.ErrTimeout
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ func NewMQTT(root string, site site.API) (*MQTT, error) {
|
|||
if err == nil {
|
||||
err = m.Listen(site)
|
||||
}
|
||||
if err != nil {
|
||||
err = fmt.Errorf("mqtt: %w", err)
|
||||
}
|
||||
|
||||
return m, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue