# HG changeset patch # User Kim Alvefur # Date 1510244351 -3600 # Node ID f1923a79c93d430cbb6678218befa87d2c28b720 # Parent 518b56d806bd9c7b9be9ebfea7e62b7b4832021c util.pubsub: Recreate itemstore if persist_items changes or resize it if max_items changes diff -r 518b56d806bd -r f1923a79c93d util/pubsub.lua --- a/util/pubsub.lua Thu Nov 09 17:22:47 2017 +0100 +++ b/util/pubsub.lua Thu Nov 09 17:19:11 2017 +0100 @@ -431,14 +431,14 @@ return false, "item-not-found"; end - for k,v in pairs(new_config) do - node_obj.config[k] = v; + 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 - 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); - end - self.data[node] = new_data; + + node_obj.config = setmetatable(new_config, {__index=self.node_defaults}); + return true; end