util.pubsub: Clear data store if it supports being cleared, otherwise fall back to creating a new one
authorKim Alvefur <zash@zash.se>
Sun, 08 Oct 2017 01:27:04 +0200
changeset 8300 ac5c90230c2c
parent 8299 e23328adca25
child 8301 dd9fa511494a
util.pubsub: Clear data store if it supports being cleared, otherwise fall back to creating a new one
util/pubsub.lua
--- a/util/pubsub.lua	Sun Oct 08 01:23:43 2017 +0200
+++ b/util/pubsub.lua	Sun Oct 08 01:27:04 2017 +0200
@@ -312,7 +312,11 @@
 	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);