Commit bb6ab9d7 authored by Diana Atanasova's avatar Diana Atanasova Committed by Trevor Conn

Wipe out command indexes when delete DeviceProfile (#1411)

Fix #1410

When Deleting DeviceProfile clean command indexes too.
Applicable only for Redis database.
Signed-off-by: default avatardifince <dianaa@vmware.com>
parent 3903abd0
......@@ -362,17 +362,19 @@ func deleteDeviceProfile(dp models.DeviceProfile, w http.ResponseWriter) error {
http.Error(w, err.Error(), http.StatusConflict)
return err
}
// Delete the profile
if err := dbClient.DeleteDeviceProfileById(dp.Id); err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return err
}
for _, command := range dp.CoreCommands {
if err := dbClient.DeleteCommandById(command.Id); err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return err
}
}
// Delete the profile
if err := dbClient.DeleteDeviceProfileById(dp.Id); err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return err
}
return nil
}
......
......@@ -532,7 +532,7 @@ func deleteDeviceProfile(conn redis.Conn, id string) error {
}
dp := contract.DeviceProfile{}
_ = unmarshalObject(object, &dp)
_ = unmarshalDeviceProfile(object, &dp)
_ = conn.Send("MULTI")
_ = conn.Send("DEL", id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment