File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
crates/core/tedge_agent/src/entity_manager Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -317,6 +317,9 @@ impl EntityStoreServer {
317
317
318
318
async fn deregister_entity ( & mut self , topic_id : & EntityTopicId ) -> Vec < EntityMetadata > {
319
319
let deleted = self . entity_store . deregister_entity ( topic_id) ;
320
+ if deleted. is_empty ( ) {
321
+ return deleted;
322
+ }
320
323
321
324
let mut topics = TopicFilter :: empty ( ) ;
322
325
for entity in deleted. iter ( ) {
@@ -338,12 +341,15 @@ impl EntityStoreServer {
338
341
}
339
342
340
343
// A single connection to retrieve all retained metadata messages for all deleted entities
341
- match self . mqtt_connector . connect ( topics) . await {
344
+ match self . mqtt_connector . connect ( topics. clone ( ) ) . await {
342
345
Ok ( mut connection) => {
343
346
while let Ok ( Some ( message) ) =
344
347
timeout ( Duration :: from_secs ( 1 ) , connection. next_message ( ) ) . await
345
348
{
346
- if message. retain && !message. payload_bytes ( ) . is_empty ( ) {
349
+ if message. retain
350
+ && !message. payload_bytes ( ) . is_empty ( )
351
+ && topics. accept ( & message)
352
+ {
347
353
let clear_msg = MqttMessage :: new ( & message. topic , "" ) . with_retain ( ) ;
348
354
if let Err ( err) = self . mqtt_publisher . send ( clear_msg) . await {
349
355
error ! (
You can’t perform that action at this time.
0 commit comments