Diff

util/pubsub.lua @ 8297:ac5c90230c2c

util.pubsub: Clear data store if it supports being cleared, otherwise fall back to creating a new one
author Kim Alvefur <zash@zash.se>
date Sun, 08 Oct 2017 01:27:04 +0200
parent 8220:a1b0fa38fca7
child 8312:6fd36e73082b
line wrap: on
line diff
--- 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);