From f7d98fa513ffe143f8e0ba987d1a5b6a1d758103 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 9 Nov 2017 17:19:11 +0100 Subject: util.pubsub: Recreate itemstore if persist_items changes or resize it if max_items changes --- util/pubsub.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/util/pubsub.lua b/util/pubsub.lua index 8122e2f2..607ec49d 100644 --- a/util/pubsub.lua +++ b/util/pubsub.lua @@ -431,14 +431,14 @@ function service:set_node_config(node, actor, new_config) return false, "item-not-found"; end - for k,v in pairs(new_config) do - node_obj.config[k] = v; - end - local new_data = self.config.itemstore(self.nodes[node].config, node); - for key, value in self.data[node]:items() do - new_data:set(key, value); + if new_config["persist_items"] ~= node_obj.config["persist_items"] then + self.data[node] = self.config.itemstore(self.nodes[node].config, node); + elseif new_config["max_items"] ~= node_obj.config["max_items"] then + self.data[node]:resize(new_config["max_items"]); end - self.data[node] = new_data; + + node_obj.config = setmetatable(new_config, {__index=self.node_defaults}); + return true; end -- cgit v1.2.3