From 2d6ea5d99d8da18bd3132f50625ca9b889a9c489 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 8 Oct 2017 01:27:04 +0200 Subject: util.pubsub: Clear data store if it supports being cleared, otherwise fall back to creating a new one --- util/pubsub.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'util') diff --git a/util/pubsub.lua b/util/pubsub.lua index 014aaa86..6dbbad20 100644 --- a/util/pubsub.lua +++ b/util/pubsub.lua @@ -312,7 +312,11 @@ function service:purge(node, actor, notify) if not node_obj then return false, "item-not-found"; end - self.data[node] = self.config.itemstore(self.nodes[node].config, node); + if self.data[node] and self.data[node].clear then + self.data[node]:clear() + else + self.data[node] = self.config.itemstore(self.nodes[node].config, node); + end self.events.fire_event("node-purged", { node = node, actor = actor }); if notify then self.config.broadcaster("purge", node, node_obj.subscribers); -- cgit v1.2.3